Path: blob/main/contrib/libarchive/cpio/test/test_cmdline.c
39507 views
/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2003-2009 Tim Kientzle4* All rights reserved.5*/6#include "test.h"78/*9* Test the command-line parsing.10*/1112DEFINE_TEST(test_cmdline)13{14FILE *f;1516/* Create an empty file. */17f = fopen("empty", "wb");18assert(f != NULL);19fclose(f);2021failure("-Q is an invalid option on every cpio program I know of");22assert(0 != systemf("%s -i -Q <empty >1.out 2>1.err", testprog));23assertEmptyFile("1.out");2425failure("-f requires an argument");26assert(0 != systemf("%s -if <empty >2.out 2>2.err", testprog));27assertEmptyFile("2.out");2829failure("-f requires an argument");30assert(0 != systemf("%s -i -f <empty >3.out 2>3.err", testprog));31assertEmptyFile("3.out");3233failure("--format requires an argument");34assert(0 != systemf("%s -i --format <empty >4.out 2>4.err", testprog));35assertEmptyFile("4.out");3637failure("--badopt is an invalid option");38assert(0 != systemf("%s -i --badop <empty >5.out 2>5.err", testprog));39assertEmptyFile("5.out");4041failure("--badopt is an invalid option");42assert(0 != systemf("%s -i --badopt <empty >6.out 2>6.err", testprog));43assertEmptyFile("6.out");4445failure("--n is ambiguous");46assert(0 != systemf("%s -i --n <empty >7.out 2>7.err", testprog));47assertEmptyFile("7.out");4849failure("--create forbids an argument");50assert(0 != systemf("%s --create=arg <empty >8.out 2>8.err", testprog));51assertEmptyFile("8.out");5253failure("-i with empty input should succeed");54assert(0 == systemf("%s -i <empty >9.out 2>9.err", testprog));55assertEmptyFile("9.out");5657failure("-o with empty input should succeed");58assert(0 == systemf("%s -o <empty >10.out 2>10.err", testprog));5960failure("-i -p is nonsense");61assert(0 != systemf("%s -i -p <empty >11.out 2>11.err", testprog));62assertEmptyFile("11.out");6364failure("-p -i is nonsense");65assert(0 != systemf("%s -p -i <empty >12.out 2>12.err", testprog));66assertEmptyFile("12.out");6768failure("-i -o is nonsense");69assert(0 != systemf("%s -i -o <empty >13.out 2>13.err", testprog));70assertEmptyFile("13.out");7172failure("-o -i is nonsense");73assert(0 != systemf("%s -o -i <empty >14.out 2>14.err", testprog));74assertEmptyFile("14.out");7576failure("-o -p is nonsense");77assert(0 != systemf("%s -o -p <empty >15.out 2>15.err", testprog));78assertEmptyFile("15.out");7980failure("-p -o is nonsense");81assert(0 != systemf("%s -p -o <empty >16.out 2>16.err", testprog));82assertEmptyFile("16.out");8384failure("-p with empty input should fail");85assert(0 != systemf("%s -p <empty >17.out 2>17.err", testprog));86assertEmptyFile("17.out");87}888990