mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 15:00:12 +00:00
tests: Make src/tests buildable
Several files in src/tests fail to build due to compiler warnings when building with --enable-checking. There are also unresolved references during the link steps. The warnings are for implicit-fallthrough unused-result unused-but-set-variable invalid-source-encoding In addition the "all" make target references a variable that is set later in the file, so the resulting list of targets is incorrect and are not built. Move libopr.a, ${LIB_hcrypto} and ${LIB_roken} from INT_LIBS into COMMON_LIBS to resolve link failures in: test-setgroups test-setpag dup2-and-unlog create-stat rm-rf write-closed2 afscp Update code that prints usage to use warnx instead of relying on __progname. Check for errors for various syscalls, to avoid "unused-result" warnings. Remove 'read_buf1' in read-write.c to avoid an "unused-but-set-variable" warning. Add a missing 'break' to a switch statement in utime-file.c to avoid an "implicit-fallthrough" warning. Add an AFS_FALLTHROUGH to fsx.c to avoid the same warning; it seems like this may be a mistake and maybe should be a "break", but match the existing fsx.c behavior at least for now, since the intended behavior isn't completely clear. Relocate the Makefile "all" target so it follows the macro definition that it references. Rename the top level Makefile target from tests to srctests for the recipe that invokes make to build src/tests. Add the necessary dependencies to the srctests target. Add srctests to the finale_notest/finale_nolibafs_notest targets Make sure the 'OpenAFS' dir exists when generating OpenAFS/Dirpath.pm and OpenAFS/Dirpath.sh. For objdir builds, it may not exist when we try to generate these files. Note The code within the src/tests directory may be out of date. This commit only ensures that the src/tests can build cleanly. Further work will be needed to validate the tests and ensure that they are still working as intended. Change-Id: Ic6d685c0dde5df25da175fe4516ce28a26443533 Reviewed-on: https://gerrit.openafs.org/15342 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Michael Meffie <mmeffie@sinenomine.net> Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
This commit is contained in:
parent
55fdd1884b
commit
80c23d958c
@ -140,7 +140,7 @@ prelude: ${TOP_INCDIR}/afs ${TOP_INCDIR}/rx ${TOP_INCDIR}/hcrypto \
|
||||
|
||||
project: cmd comerr
|
||||
|
||||
tests: all
|
||||
srctests: sys rx lwp util auth fsint comerr opr hcrypto ${DIR_roken}
|
||||
+${COMPILE_PART1} tests ${COMPILE_PART2}
|
||||
|
||||
config: prelude
|
||||
@ -623,7 +623,7 @@ finale_notest: project cmd comerr afsd butc tbutc tbudb @ENABLE_KERNEL_MODULE@ \
|
||||
bozo @VFSCK@ volser tvolser tsalvaged dviced dvolser libafscp \
|
||||
venus venustests update xstat afsmonitor rxdebug libafsrpc rfc3961 \
|
||||
hcrypto libafsauthent libadmin man-pages tools platform kopenafs \
|
||||
authtools $(DIR_roken) rxgk rx_test rxkad_test
|
||||
authtools $(DIR_roken) rxgk rx_test rxkad_test srctests
|
||||
+${COMPILE_PART1} finale ${COMPILE_PART2}
|
||||
|
||||
finale_nolibafs_notest: project cmd comerr afsd butc tbutc tbudb libuafs audit kauth \
|
||||
@ -631,7 +631,7 @@ finale_nolibafs_notest: project cmd comerr afsd butc tbutc tbudb libuafs audit k
|
||||
volser tvolser tsalvaged dviced dvolser libafscp venus venustests \
|
||||
update xstat afsmonitor rxdebug libafsrpc rfc3961 hcrypto \
|
||||
libafsauthent libadmin man-pages tools platform kopenafs \
|
||||
authtools $(DIR_roken) rxgk rx_test rxkad_test
|
||||
authtools $(DIR_roken) rxgk rx_test rxkad_test srctests
|
||||
+${COMPILE_PART1} finale ${COMPILE_PART2}
|
||||
|
||||
finale: finale_notest test_build
|
||||
|
@ -4,9 +4,6 @@ include @TOP_OBJDIR@/src/config/Makefile.lwp
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
all: run-tests OpenAFS/Dirpath.pm $(TEST_PROGRAMS) OpenAFS/Dirpath.sh
|
||||
@chmod +x run-tests
|
||||
|
||||
SYS_LIBS = ${TOP_LIBDIR}/libsys.a \
|
||||
${TOP_LIBDIR}/librx.a \
|
||||
${TOP_LIBDIR}/liblwp.a \
|
||||
@ -22,12 +19,12 @@ INT_LIBS = ${TOP_LIBDIR}/libafsint.a \
|
||||
${TOP_LIBDIR}/liblwp.a \
|
||||
${TOP_LIBDIR}/libafscom_err.a \
|
||||
${TOP_LIBDIR}/util.a \
|
||||
${TOP_LIBDIR}/libafsrfc3961.a \
|
||||
${TOP_LIBDIR}/libopr.a \
|
||||
$(LIB_roken) \
|
||||
$(LIB_hcrypto)
|
||||
${TOP_LIBDIR}/libafsrfc3961.a
|
||||
|
||||
COMMON_LIBS = ${LIBS}
|
||||
COMMON_LIBS = ${LIBS} \
|
||||
${TOP_LIBDIR}/libopr.a \
|
||||
${LIB_hcrypto} \
|
||||
${LIB_roken}
|
||||
|
||||
TEST_PROGRAMS = write-ro-file hello-world read-vs-mmap read-vs-mmap2 \
|
||||
mmap-and-read large-dir large-dir2 large-dir3 mountpoint \
|
||||
@ -82,6 +79,9 @@ TEST_SRCS = write-ro-file.c read-vs-mmap.c read-vs-mmap2.c \
|
||||
|
||||
EXTRA_OBJS = err.o errx.o warn.o warnx.o vwarn.o vwarnx.o verr.o verrx.o warnerr.o
|
||||
|
||||
all: run-tests OpenAFS/Dirpath.pm $(TEST_PROGRAMS) OpenAFS/Dirpath.sh
|
||||
@chmod +x run-tests
|
||||
|
||||
fsx: fsx.o $(EXTRA_OBJS)
|
||||
$(AFS_LDRULE) fsx.o $(EXTRA_OBJS) $(COMMON_LIBS)
|
||||
|
||||
@ -293,6 +293,7 @@ check-fast: run-tests $(TEST_PROGRAMS)
|
||||
# until make is run so we resort to creating the
|
||||
# configuration at make time.
|
||||
OpenAFS/Dirpath.pm: Makefile
|
||||
mkdir -p OpenAFS
|
||||
@echo "Creating OpenAFS/Dirpath.pm"
|
||||
@echo "# This is -*- perl -*-" >$@
|
||||
@echo "# auto-generated by src/tests/Makefile" >>$@
|
||||
@ -336,6 +337,7 @@ OpenAFS/Dirpath.pm: Makefile
|
||||
@echo "1;" >>$@
|
||||
|
||||
OpenAFS/Dirpath.sh: Makefile
|
||||
mkdir -p OpenAFS
|
||||
@echo "Creating OpenAFS/Dirpath.sh"
|
||||
@echo "# auto-generated by src/tests/Makefile" >$@
|
||||
@echo "# source or '.' in this file in shell" >>$@
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
@ -80,10 +80,18 @@ main(int argc, char **argv)
|
||||
if (setgroups(1, groups))
|
||||
errx(1, "setgroups failed");
|
||||
|
||||
setgid(gid);
|
||||
setuid(uid);
|
||||
setegid(gid);
|
||||
seteuid(uid);
|
||||
if (setgid(gid) != 0) {
|
||||
err(1, "setgid failed");
|
||||
}
|
||||
if (setuid(uid) != 0) {
|
||||
err(1, "setuid failed");
|
||||
}
|
||||
if (setegid(gid) != 0) {
|
||||
err(1, "setegid failed");
|
||||
}
|
||||
if (seteuid(uid) != 0) {
|
||||
err(1, "seteuid failed");
|
||||
}
|
||||
}
|
||||
|
||||
execvp(prog, &argv[2]);
|
||||
|
@ -66,7 +66,7 @@ creat_dirs(int count)
|
||||
static void
|
||||
usage(int ret)
|
||||
{
|
||||
fprintf(stderr, "%s number-of-dirs\n", __progname);
|
||||
warnx("number-of-dirs");
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ creat_files(int count, long startsize)
|
||||
static void
|
||||
usage(int ret)
|
||||
{
|
||||
fprintf(stderr, "%s number-of-files size-of-files\n", __progname);
|
||||
warnx("number-of-files size-of-files");
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ unlink_file(const char *name)
|
||||
static void
|
||||
usage(int ret)
|
||||
{
|
||||
fprintf(stderr, "%s [file|dir] number-of-dirs\n", __progname);
|
||||
warnx("[file|dir] number-of-dirs");
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,8 @@
|
||||
#include <afsconfig.h>
|
||||
#include <afs/param.h>
|
||||
|
||||
#include <roken.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -52,7 +54,7 @@
|
||||
static void
|
||||
usage(int ret)
|
||||
{
|
||||
fprintf(stderr, "%s file\n", __progname);
|
||||
warnx("file");
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ verify_contents(int count)
|
||||
static void
|
||||
usage(int ret)
|
||||
{
|
||||
fprintf(stderr, "%s number-of-symlinks\n", __progname);
|
||||
warnx("number-of-symlinks");
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
|
@ -67,5 +67,6 @@ void vwarnx(const char *fmt, va_list ap)
|
||||
__attribute__ ((format(printf, 1, 0)));
|
||||
void warnx(const char *fmt, ...)
|
||||
__attribute__ ((format(printf, 1, 2)));
|
||||
|
||||
void warnerr(int doerrno, const char *fmt, va_list ap)
|
||||
__attribute__ ((format(printf, 2, 0)));
|
||||
#endif /* __ERR_H__ */
|
||||
|
@ -17,12 +17,10 @@
|
||||
#if defined(sun) || defined(_UWIN) || defined(__linux)
|
||||
# include <sys/param.h>
|
||||
# include <limits.h>
|
||||
# include <time.h>
|
||||
# include <strings.h>
|
||||
# define MAP_FILE 0
|
||||
#else
|
||||
# include <sys/dirent.h>
|
||||
#endif
|
||||
#include <time.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/mman.h>
|
||||
#include <limits.h>
|
||||
@ -359,14 +357,20 @@ check_trunc_hack(void)
|
||||
{
|
||||
struct stat statbuf;
|
||||
|
||||
ftruncate(fd, (off_t) 0);
|
||||
ftruncate(fd, (off_t) 100000);
|
||||
if (ftruncate(fd, (off_t) 0) != 0) {
|
||||
prterr("check_trunc_hack ftruncate(0)");
|
||||
}
|
||||
if (ftruncate(fd, (off_t) 100000) != 0) {
|
||||
prterr("check_trunc_hack ftruncate(100000)");
|
||||
}
|
||||
fstat(fd, &statbuf);
|
||||
if (statbuf.st_size != (off_t) 100000) {
|
||||
prt("no extend on truncate! not posix!\n");
|
||||
exit(130);
|
||||
}
|
||||
ftruncate(fd, 0);
|
||||
if (ftruncate(fd, 0) != 0) {
|
||||
prterr("check_trunc_hack ftruncate(0) again");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -884,6 +888,13 @@ main(int argc, char **argv)
|
||||
if (monitorend == 0)
|
||||
monitorend = -1; /* aka infinity */
|
||||
debug = 1;
|
||||
|
||||
/*
|
||||
* Falling through to 'n' seems like a mistake, but this is what
|
||||
* the historical 'fsx' tool has always done. We do the same here,
|
||||
* for compatibility.
|
||||
*/
|
||||
AFS_FALLTHROUGH;
|
||||
case 'n':
|
||||
sizechecks = 0;
|
||||
break;
|
||||
|
@ -126,7 +126,7 @@ creat_files(const char *dirname, int count)
|
||||
static void
|
||||
usage(int ret)
|
||||
{
|
||||
fprintf(stderr, "%s directory number-of-files\n", __progname);
|
||||
warnx("directory number-of-files");
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ creat_files(const char *dirname, int count)
|
||||
static void
|
||||
usage(int ret)
|
||||
{
|
||||
fprintf(stderr, "%s directory number-of-files\n", __progname);
|
||||
warnx("directory number-of-files");
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ creat_files(const char *dirname, int count)
|
||||
static void
|
||||
usage(int ret)
|
||||
{
|
||||
fprintf(stderr, "%s directory number-of-files\n", __progname);
|
||||
warnx("directory number-of-files");
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,6 @@ main(int argc, char **argv)
|
||||
const char *file = "foo";
|
||||
const size_t sz = 16384;
|
||||
char *random_buf;
|
||||
char *read_buf1;
|
||||
char *read_buf2;
|
||||
int fd;
|
||||
|
||||
@ -126,7 +125,7 @@ main(int argc, char **argv)
|
||||
write_null_file(fd, sz);
|
||||
if (lseek(fd, 0, SEEK_SET) < 0)
|
||||
err(1, "lseek");
|
||||
read_buf1 = read_file(fd, sz);
|
||||
read_file(fd, sz);
|
||||
if (lseek(fd, 0, SEEK_SET) < 0)
|
||||
err(1, "lseek");
|
||||
random_buf = write_random_file(fd, sz);
|
||||
|
@ -77,7 +77,7 @@ verify_inodes(const char *dirname)
|
||||
static void
|
||||
usage(int ret)
|
||||
{
|
||||
fprintf(stderr, "%s [directory]\n", __progname);
|
||||
warnx("[directory]");
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
|
@ -69,14 +69,14 @@ look_at_file(char *name)
|
||||
static void
|
||||
usage(int ret)
|
||||
{
|
||||
fprintf(stderr, "%s\n", __progname);
|
||||
warnx(NULL);
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char *file = "åäö";
|
||||
char *file = "\xe5\xe4\xf6";
|
||||
|
||||
|
||||
if (argc != 1)
|
||||
|
@ -62,7 +62,9 @@ getcwd_worker(int num)
|
||||
for (i = 0; i < WORKER_TIMES; ++i) {
|
||||
char buf[256];
|
||||
|
||||
getcwd(buf, sizeof(buf));
|
||||
if (getcwd(buf, sizeof(buf)) == NULL) {
|
||||
err(1, "getcwd %s", name);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -138,7 +140,9 @@ stat_worker(int num)
|
||||
if (chdir(name) < 0)
|
||||
err(1, "chdir %s", name);
|
||||
for (i = 0; i < WORKER_TIMES; ++i) {
|
||||
getcwd(buf, sizeof(buf));
|
||||
if (getcwd(buf, sizeof(buf)) == NULL) {
|
||||
err(1, "getcwd %s", name);
|
||||
}
|
||||
stat(buf, &sb);
|
||||
}
|
||||
return 0;
|
||||
|
@ -64,6 +64,7 @@ main(int argc, char **argv)
|
||||
len = atoi(argv[1]);
|
||||
if (len == 0)
|
||||
errx(1, "invalid len");
|
||||
break;
|
||||
default:
|
||||
errx(1, "argv != [12]");
|
||||
}
|
||||
@ -81,7 +82,9 @@ main(int argc, char **argv)
|
||||
ret = ftruncate(fd, len);
|
||||
fstat(fd, &sb);
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
write(fd, buf, len);
|
||||
if (write(fd, buf, len) != len) {
|
||||
errx(1, "write");
|
||||
}
|
||||
fstat(fd, &sb);
|
||||
|
||||
t.modtime = t.actime = time(NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user