diff options
| author | Emmanuel Dreyfus <manu@netbsd.org> | 2014-11-26 09:59:25 +0100 |
|---|---|---|
| committer | Vijay Bellur <vbellur@redhat.com> | 2014-11-26 04:18:47 -0800 |
| commit | 51eaed7fb243a989fdf96461ba2d9acfc07977f8 (patch) | |
| tree | e371a00cbfe45b74d236472b9896a8adc4f5bb57 /tests/bugs/bug-860663.c | |
| parent | c147c36a70505ff239cef48030422840abd3fbcd (diff) | |
Regression test portability: batch of bugs (volume 2)
Fix various regression test portability in tests/bugs.
bug-861542.t
- Avoid syntax specific to GNU sed.
bug-860663.t
- Command argument length is system dependent, and specifying 1000 file
path may overflow it. Use a C program to do the job in a portable and
efficient way.
- Add a test that we created the specified amount of files.
bug-858242.c, bug-808400-fcntl.c, bug-808400-flock.c
- fstat64() is Linux-specific. Define it as fstat for other systems.
bug-823081.t
- Use portable tail -n instead of tail --lines
In many tests:
- Do not assume python interpreter name. Use $PYTHON as defined
in env.rc by configure.
utils/libcxattr.py
- If python version is 2.6 or higher, use a portable mechanism to
recover errno. The original version is retained for python version
2.5 and earlier but it only works on Linux.
BUG: 1129939
Change-Id: If2fea1ffec5cc6ab2de426fb200e884450afe61b
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/9097
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'tests/bugs/bug-860663.c')
| -rw-r--r-- | tests/bugs/bug-860663.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/bugs/bug-860663.c b/tests/bugs/bug-860663.c new file mode 100644 index 00000000000..6f6d0696e64 --- /dev/null +++ b/tests/bugs/bug-860663.c @@ -0,0 +1,42 @@ +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <fcntl.h> +#include <string.h> +#include <err.h> +#include <sys/param.h> + +int +main(argc, argv) + int argc; + char **argv; +{ + char *basepath; + char path[MAXPATHLEN + 1]; + unsigned int count; + int i, fd; + + if (argc != 3) + errx(1, "usage: %s path count", argv[0]); + + basepath = argv[1]; + count = atoi(argv[2]); + + if (count > 999999) + errx(1, "count too big"); + + if (strlen(basepath) > MAXPATHLEN - 6) + errx(1, "path too long"); + + for (i = 0; i < count; i++) { + (void)sprintf(path, "%s%06d", basepath, i); + + if ((fd = open(path, O_CREAT|O_RDWR, 0644)) == -1) + err(1, "create %s failed", path); + + if (close(fd) != 0) + warn("close %s failed", path); + } + + return 0; +} |
