• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) Linux Test Project, 2003-2021
4#
5# Test basic functionality of cpio command
6
7TST_TESTFUNC=cpio_test
8TST_NEEDS_TMPDIR=1
9TST_NEEDS_CMDS="cpio"
10TST_SETUP="setup"
11. tst_test.sh
12
13
14setup()
15{
16	if ! cpio --help 2>&1 | grep -q -- '-o.*Create'; then
17		tst_brk TCONF "-o flag not supported"
18	fi
19
20	ARCHIVE_FORMAT=
21
22	if cpio 2>&1 | grep -q 'BusyBox'; then
23		ARCHIVE_FORMAT="-H newc"
24	fi
25}
26
27cpio_test()
28{
29	ROD mkdir "dir"
30	for i in a b c d e f g h i j k l m n o p q r s t u v w x y z; do
31		ROD echo "Test" > "dir/$i"
32	done
33
34	ROD find dir -type f > filelist
35	EXPECT_PASS cpio -o $ARCHIVE_FORMAT \> cpio.out \< filelist
36	ROD mv "dir" "dir_orig"
37	ROD mkdir "dir"
38	EXPECT_PASS cpio -i \< cpio.out
39
40	if diff -r "dir" "dir_orig"; then
41		tst_res TPASS "Directories dir and dir_orig are equal"
42	else
43		tst_res TFAIL "Directories dir and dir_orig differ"
44		ls -R dir_orig
45		echo
46		ls -R dir
47	fi
48}
49
50tst_run
51