summaryrefslogtreecommitdiff
path: root/source4/lib/replace
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2006-10-17 14:54:47 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:21:19 -0500
commit8acb0575c716c8ca680835764cd3bc5483f3707c (patch)
tree615bf2db4d5bfd2262830e34082b34220503d0fb /source4/lib/replace
parentd60c86364c396adee36aa5d353aa782bbf26e01e (diff)
downloadsamba-8acb0575c716c8ca680835764cd3bc5483f3707c.tar.gz
samba-8acb0575c716c8ca680835764cd3bc5483f3707c.tar.bz2
samba-8acb0575c716c8ca680835764cd3bc5483f3707c.zip
r19373: Merge changes from subunit branch: Convert libreplace testsuite to a
standalone program that speaks subunit. (This used to be commit 48d316e7594dfc29b8e6a710e32bb5a6a036b7cf)
Diffstat (limited to 'source4/lib/replace')
-rw-r--r--source4/lib/replace/config.mk4
-rw-r--r--source4/lib/replace/test/os2_delete.c4
-rw-r--r--source4/lib/replace/test/testsuite.c40
3 files changed, 24 insertions, 24 deletions
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