From 8acb0575c716c8ca680835764cd3bc5483f3707c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 17 Oct 2006 14:54:47 +0000 Subject: r19373: Merge changes from subunit branch: Convert libreplace testsuite to a standalone program that speaks subunit. (This used to be commit 48d316e7594dfc29b8e6a710e32bb5a6a036b7cf) --- source4/lib/basic.mk | 1 + source4/lib/replace/config.mk | 4 ++++ source4/lib/replace/test/os2_delete.c | 4 ++-- source4/lib/replace/test/testsuite.c | 40 ++++++++++++++++------------------- 4 files changed, 25 insertions(+), 24 deletions(-) create mode 100644 source4/lib/replace/config.mk (limited to 'source4/lib') diff --git a/source4/lib/basic.mk b/source4/lib/basic.mk index b5a3a031eb..4abb2c8430 100644 --- a/source4/lib/basic.mk +++ b/source4/lib/basic.mk @@ -4,6 +4,7 @@ include socket/config.mk include charset/config.mk include ldb/config.mk include talloc/config.mk +include replace/config.mk include tdb/config.mk include tls/config.mk include registry/config.mk diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk new file mode 100644 index 0000000000..ff80955ffe --- /dev/null +++ b/source4/lib/replace/config.mk @@ -0,0 +1,4 @@ +[BINARY::REPLACE] +OBJ_FILES = test/testsuite.o test/os2_delete.o +PRIVATE_DEPENDENCIES = LIBREPLACE +INSTALLDIR = TORTUREDIR/LOCAL diff --git a/source4/lib/replace/test/os2_delete.c b/source4/lib/replace/test/os2_delete.c index 8501e0bb40..c8abfccff9 100644 --- a/source4/lib/replace/test/os2_delete.c +++ b/source4/lib/replace/test/os2_delete.c @@ -21,7 +21,7 @@ static int test_readdir_os2_delete_ret; -#define FAILED(d) (fprintf(stderr, "Failed for %s - %d = %s\n", d, errno, strerror(errno)), test_readdir_os2_delete_ret = 1, 1) +#define FAILED(d) (printf("failure: readdir [\nFailed for %s - %d = %s\n]\n", d, errno, strerror(errno)), test_readdir_os2_delete_ret = 1, 1) #ifndef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) @@ -107,7 +107,7 @@ int test_readdir_os2_delete(void) } closedir(d); - printf("Deleted %d files of %d\n", total_deleted, NUM_FILES); + fprintf(stderr, "Deleted %d files of %d\n", total_deleted, NUM_FILES); rmdir(TESTDIR) == 0 || FAILED("rmdir"); diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index d45304103f..3e20e22e45 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -57,26 +57,28 @@ static int test_ftruncate(void) struct stat st; int fd; const int size = 1234; - printf("testing ftruncate\n"); + printf("test: ftruncate\n"); unlink(TESTFILE); fd = open(TESTFILE, O_RDWR|O_CREAT, 0600); if (fd == -1) { - printf("creating '%s' failed - %s\n", TESTFILE, strerror(errno)); + printf("failure: ftruncate [\n" + "creating '%s' failed - %s\n]\n", TESTFILE, strerror(errno)); return false; } if (ftruncate(fd, size) != 0) { - printf("ftruncate failed - %s\n", strerror(errno)); + printf("failure: ftruncate [\n%s\n]\n", strerror(errno)); return false; } if (fstat(fd, &st) != 0) { - printf("fstat failed - %s\n", strerror(errno)); + printf("failure: ftruncate [\nfstat failed - %s\n]\n", strerror(errno)); return false; } if (st.st_size != size) { - printf("ftruncate gave wrong size %d - expected %d\n", + printf("failure: ftruncate [\ngave wrong size %d - expected %d\n]\n", (int)st.st_size, size); return false; } + printf("success: ftruncate\n"); return true; } @@ -98,13 +100,14 @@ static int test_strlcpy(void) { NULL, 0 } }; int i; - printf("testing strlcpy\n"); + printf("test: strlcpy\n"); for (i=0;tests[i].src;i++) { if (strlcpy(buf, tests[i].src, sizeof(buf)) != tests[i].result) { - printf("strlcpy test %d failed\n", i); + printf("failure: strlcpy [\ntest %d failed\n]\n", i); return false; } } + printf("success: strlcpy\n"); return true; } @@ -146,8 +149,9 @@ static int test_strdup(void) static int test_setlinebuf(void) { - printf("testing setlinebuf\n"); + printf("test: setlinebuf\n"); setlinebuf(stdout); + printf("success: setlinebuf\n"); return true; } @@ -233,10 +237,11 @@ extern int test_readdir_os2_delete(void); static int test_readdir(void) { - printf("testing readdir\n"); + printf("test: readdir\n"); if (test_readdir_os2_delete() != 0) { return false; } + printf("success: readdir\n"); return true; } @@ -373,7 +378,7 @@ static int test_MAX(void) struct torture_context; -bool torture_local_replace(struct torture_context *torture) +int main() { bool ret = true; ret &= test_ftruncate(); @@ -420,16 +425,7 @@ bool torture_local_replace(struct torture_context *torture) ret &= test_MIN(); ret &= test_MAX(); - return ret; + if (ret) + return 0; + return -1; } - -#if _SAMBA_BUILD_<4 -int main(void) -{ - if (!torture_local_replace(NULL)) { - printf("ERROR: TESTSUITE FAILED\n"); - return -1; - } - return 0; -} -#endif -- cgit