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.
This commit is contained in:
Michihiro NAKAJIMA committed 2014-06-29 16:12:34 +09:00
1 parent fa6b6a41b1
commit 41c37ee3fc
8 files changed
+100

No files matched your search

+23
View 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)
{
+2
View 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;
+23
View 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)
{
+2
View 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;
+23
View 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)
{
+2
View 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.
+23
View 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)
{
+2
View 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;