X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fliblustre%2Ftests%2Fsanity.c;h=e46f4803aad23563deea4b6a38057cde46a165db;hp=16014bc055d5579e65be395c135c0c5ff05b0f61;hb=b703901c435dac562a869d5eea5e96b2ce342d42;hpb=027fddd052930686339e2067c6869d0846563ffe diff --git a/lustre/liblustre/tests/sanity.c b/lustre/liblustre/tests/sanity.c index 16014bc..e46f480 100644 --- a/lustre/liblustre/tests/sanity.c +++ b/lustre/liblustre/tests/sanity.c @@ -1333,6 +1333,46 @@ int t55(char *name) LEAVE(); } +/* + * getdirentries should return -1 and set errno to EINVAL when the size + * specified as an argument is too small to contain at least one entry + * (see bugzilla ticket 12229) + */ +int t56(char *name) +{ + int fd; + size_t nbytes; + off_t basep = 0; + ssize_t rc = 0; + struct dirent dir; + + ENTRY("getdirentries should fail if nbytes is too small"); + + /* Set count to be very small. The result should be EINVAL */ + nbytes = 8; + + /* open the directory and call getdirentries */ + fd = t_opendir(lustre_path); + + rc = getdirentries(fd, (char *)&dir, nbytes, &basep); + + if (rc != -1) { + printf("Test failed: getdirentries returned %d\n", rc); + t_close(fd); + return -1; + } + if (errno != EINVAL) { + printf("Test failed: getdirentries returned %d but errno is set" + " to %d (should be EINVAL)\n", rc, errno); + t_close(fd); + return -1; + } + t_close(fd); + + LEAVE(); +} + + extern void __liblustre_setup_(void); extern void __liblustre_cleanup_(void); @@ -1380,6 +1420,7 @@ struct testlist { { t53, "53" }, { t54, "54" }, { t55, "55" }, + { t56, "56" }, { NULL, NULL } };