diff options
author | Michihiro NAKAJIMA <ggcueroad@gmail.com> | 2014-06-29 16:12:34 +0900 |
---|---|---|
committer | Michihiro NAKAJIMA <ggcueroad@gmail.com> | 2014-06-29 16:12:34 +0900 |
commit | 41c37ee3fc771e69e9c2e5e6b6df33b47d239a46 (patch) | |
tree | 050106867af4b591182887ce9a1dbef117d995cf /cat/test | |
parent | fa6b6a41b173cf93e019528368b0c0aa24f8ac43 (diff) | |
download | libarchive-41c37ee3fc771e69e9c2e5e6b6df33b47d239a46.tar.gz |
Add a test utility function, copy_reference_file simply coping
a sample file to the current directory of a running test.
A uudecode filter test will use it for its new test.
TODO: make a symbolic link file insted of copying a sample file.
Historically, libarchive cannot handle uuencoded files when
libarchive's test suit was made. Now libarchive can handle it
directly by uudecode filter, I think, we can reduce copying
sample files to the directory test program expects they are
on an isolated directory for their test.
Diffstat (limited to 'cat/test')
-rw-r--r-- | cat/test/main.c | 23 | ||||
-rw-r--r-- | cat/test/test.h | 2 |
2 files changed, 25 insertions, 0 deletions
diff --git a/cat/test/main.c b/cat/test/main.c index d96a64a2..649e0099 100644 --- a/cat/test/main.c +++ b/cat/test/main.c @@ -2203,6 +2203,29 @@ extract_reference_file(const char *name) fclose(in); } +void +copy_reference_file(const char *name) +{ + char buff[1024]; + FILE *in, *out; + size_t rbytes; + + sprintf(buff, "%s/%s", refdir, name); + in = fopen(buff, "rb"); + failure("Couldn't open reference file %s", buff); + assert(in != NULL); + if (in == NULL) + return; + /* Now, decode the rest and write it. */ + /* Not a lot of error checking here; the input better be right. */ + out = fopen(name, "wb"); + while ((rbytes = fread(buff, 1, sizeof(buff), in)) > 0) { + fwrite(buff, 1, rbytes, out); + } + fclose(out); + fclose(in); +} + int is_LargeInode(const char *file) { diff --git a/cat/test/test.h b/cat/test/test.h index 74332195..fa3e9c57 100644 --- a/cat/test/test.h +++ b/cat/test/test.h @@ -305,6 +305,8 @@ char *slurpfile(size_t *, const char *fmt, ...); /* Extracts named reference file to the current directory. */ void extract_reference_file(const char *); +/* Copies named reference file to the current directory. */ +void copy_reference_file(const char *); /* Path to working directory for current test */ extern const char *testworkdir; |