]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Add a test utility function, copy_reference_file simply coping
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Sun, 29 Jun 2014 07:12:34 +0000 (16:12 +0900)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Sun, 29 Jun 2014 07:12:34 +0000 (16:12 +0900)
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.

cat/test/main.c
cat/test/test.h
cpio/test/main.c
cpio/test/test.h
libarchive/test/main.c
libarchive/test/test.h
tar/test/main.c
tar/test/test.h

index d96a64a286d7c8096b87c11d60014cacc68555d7..649e0099255d69f52686cfc1926fbc45423575aa 100644 (file)
@@ -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)
 {
index 7433219546acaecd35f7a17242905d3fa72b976a..fa3e9c57ecfd984b4542478fea603385bcc6efde 100644 (file)
@@ -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;
index 92f216333630c3035c2fa1f9ef9547e8603eeecc..2b5ab0cc830e40ae27dfb80bdbede95a0616599e 100644 (file)
@@ -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)
 {
index 41ab019b24e1491b7fb3b979b2f6ae6742727365..d645cad86a2d6d50556e10c7a4c60ec6c3e34866 100644 (file)
@@ -303,6 +303,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;
index d21640ee5b69892e00f70123f98b0a7b649f01d4..28afb9d6e7278191f8918e23d8cb557cfc73f6c6 100644 (file)
@@ -2231,6 +2231,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)
 {
index 105001c7c72f585e020bab6ce1d4302cb6c75c12..aa1df32f1d2079de5762eca649b8f4173da918bc 100644 (file)
@@ -308,6 +308,8 @@ void dumpfile(const char *filename, void *, size_t);
 
 /* 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 *);
 
 /* Extracts a list of files to the current directory.
  * List must be NULL terminated.
index 9efdf51f96549e0268aed9a9e50db4d436ef0413..455921ba2a9ef8185ed01dfe0df9641dcde4850a 100644 (file)
@@ -2204,6 +2204,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)
 {
index 7433219546acaecd35f7a17242905d3fa72b976a..fa3e9c57ecfd984b4542478fea603385bcc6efde 100644 (file)
@@ -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;