]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Cpio test: Expected error message depends on local strerror()
authorTim Kientzle <kientzle@acm.org>
Sun, 2 Sep 2018 07:25:08 +0000 (00:25 -0700)
committerGrzegorz Antoniak <ga@anadoxin.org>
Sat, 8 Sep 2018 05:22:38 +0000 (07:22 +0200)
cpio/test/test_basic.c
cpio/test/test_format_newc.c

index f3a048002a5557dace55166dba3b3e65caad39ab..6e45d18569831a8ebf071b92cf087240950f2d6d 100644 (file)
@@ -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. */
index d2daa46ab71c6c7d0db12a64f24ff2800ddb4f24..258640443fe6121e0b278b3809a12aca27e55c00 100644 (file)
@@ -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. */