Commit 92666772 authored by Tim Kientzle's avatar Tim Kientzle

Cpio test: Expected error message depends on local strerror()

parent 4925fd0b
......@@ -144,49 +144,79 @@ DEFINE_TEST(test_basic)
/* File with 10 bytes content. */
assertMakeFile("file", 0644, "1234567890");
fprintf(filelist, "file\n");
if (is_LargeInode("file"))
if (is_LargeInode("file")) {
strncat(result,
"bsdcpio: file: large inode number truncated: "
"Numerical result out of range\n",
"bsdcpio: file: large inode number truncated: ",
sizeof(result) - strlen(result) -1);
strncat(result,
strerror(ERANGE),
sizeof(result) - strlen(result) -1);
strncat(result,
"\n",
sizeof(result) - strlen(result) -1);
}
/* hardlink to above file. */
assertMakeHardlink("linkfile", "file");
fprintf(filelist, "linkfile\n");
if (is_LargeInode("linkfile"))
if (is_LargeInode("linkfile")) {
strncat(result,
"bsdcpio: linkfile: large inode number truncated: ",
sizeof(result) - strlen(result) -1);
strncat(result,
strerror(ERANGE),
sizeof(result) - strlen(result) -1);
strncat(result,
"bsdcpio: linkfile: large inode number truncated: "
"Numerical result out of range\n",
"\n",
sizeof(result) - strlen(result) -1);
}
/* Symlink to above file. */
if (canSymlink()) {
assertMakeSymlink("symlink", "file");
fprintf(filelist, "symlink\n");
if (is_LargeInode("symlink"))
if (is_LargeInode("symlink")) {
strncat(result,
"bsdcpio: symlink: large inode number truncated: ",
sizeof(result) - strlen(result) -1);
strncat(result,
"bsdcpio: symlink: large inode number truncated: "
"Numerical result out of range\n",
strerror(ERANGE),
sizeof(result) - strlen(result) -1);
strncat(result,
"\n",
sizeof(result) - strlen(result) -1);
}
}
/* Another file with different permissions. */
assertMakeFile("file2", 0777, "1234567890");
fprintf(filelist, "file2\n");
if (is_LargeInode("file2"))
if (is_LargeInode("file2")) {
strncat(result,
"bsdcpio: file2: large inode number truncated: ",
sizeof(result) - strlen(result) -1);
strncat(result,
strerror(ERANGE),
sizeof(result) - strlen(result) -1);
strncat(result,
"bsdcpio: file2: large inode number truncated: "
"Numerical result out of range\n",
"\n",
sizeof(result) - strlen(result) -1);
}
/* Directory. */
assertMakeDir("dir", 0775);
fprintf(filelist, "dir\n");
if (is_LargeInode("dir"))
if (is_LargeInode("dir")) {
strncat(result,
"bsdcpio: dir: large inode number truncated: ",
sizeof(result) - strlen(result) -1);
strncat(result,
"bsdcpio: dir: large inode number truncated: "
"Numerical result out of range\n",
strerror(ERANGE),
sizeof(result) - strlen(result) -1);
strncat(result,
"\n",
sizeof(result) - strlen(result) -1);
}
strncat(result, "2 blocks\n", sizeof(result) - strlen(result) -1);
/* All done. */
......
......@@ -124,26 +124,42 @@ DEFINE_TEST(test_format_newc)
/* Setup result message. */
memset(result, 0, sizeof(result));
if (is_LargeInode("file1"))
if (is_LargeInode("file1")) {
strncat(result,
"bsdcpio: file1: large inode number truncated: "
"Numerical result out of range\n",
"bsdcpio: file1: large inode number truncated: ",
sizeof(result) - strlen(result) -1);
if (canSymlink() && is_LargeInode("symlink"))
strncat(result, strerror(ERANGE),
sizeof(result) - strlen(result) -1);
strncat(result, "\n",
sizeof(result) - strlen(result) -1);
}
if (canSymlink() && is_LargeInode("symlink")) {
strncat(result,
"bsdcpio: symlink: large inode number truncated: "
"Numerical result out of range\n",
"bsdcpio: symlink: large inode number truncated: ",
sizeof(result) - strlen(result) -1);
if (is_LargeInode("dir"))
strncat(result, strerror(ERANGE),
sizeof(result) - strlen(result) -1);
strncat(result, "\n",
sizeof(result) - strlen(result) -1);
}
if (is_LargeInode("dir")) {
strncat(result,
"bsdcpio: dir: large inode number truncated: "
"Numerical result out of range\n",
"bsdcpio: dir: large inode number truncated: ",
sizeof(result) - strlen(result) -1);
if (is_LargeInode("hardlink"))
strncat(result, strerror(ERANGE),
sizeof(result) - strlen(result) -1);
strncat(result, "\n",
sizeof(result) - strlen(result) -1);
}
if (is_LargeInode("hardlink")) {
strncat(result,
"bsdcpio: hardlink: large inode number truncated: "
"Numerical result out of range\n",
"bsdcpio: hardlink: large inode number truncated: ",
sizeof(result) - strlen(result) -1);
strncat(result, strerror(ERANGE),
sizeof(result) - strlen(result) -1);
strncat(result, "\n",
sizeof(result) - strlen(result) -1);
}
/* Record some facts about what we just created: */
now = time(NULL); /* They were all created w/in last two seconds. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment