xref: /aosp_15_r20/external/elfutils/tests/run-ar-N.sh (revision 7304104da70ce23c86437a01be71edd1a2d7f37e)
1#! /usr/bin/env bash
2# Copyright (C) 2022 Mark J. Wielaard <[email protected]>
3# This file is part of elfutils.
4#
5# This file is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3 of the License, or
8# (at your option) any later version.
9#
10# elfutils is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18. $srcdir/test-subr.sh
19
20tempfiles testfile test.ar
21
22echo create test.ar with 3 testfile
23echo 1 > testfile
24testrun ${abs_top_builddir}/src/ar -vr test.ar testfile
25echo 2 > testfile
26testrun ${abs_top_builddir}/src/ar -vq test.ar testfile
27testrun ${abs_top_builddir}/src/ar -t test.ar
28echo 3 > testfile
29testrun ${abs_top_builddir}/src/ar -vq test.ar testfile
30testrun_compare ${abs_top_builddir}/src/ar -t test.ar << EOF
31testfile
32testfile
33testfile
34EOF
35
36echo list content of testfile 1 2 3
37testrun ${abs_top_builddir}/src/ar -vx -N 1 test.ar testfile
38diff -u testfile - << EOF
391
40EOF
41testrun ${abs_top_builddir}/src/ar -vx -N 2 test.ar testfile
42diff -u testfile - << EOF
432
44EOF
45testrun ${abs_top_builddir}/src/ar -vx -N 3 test.ar testfile
46diff -u testfile - << EOF
473
48EOF
49
50echo delete testfile 2
51testrun ${abs_top_builddir}/src/ar -vd -N 2 test.ar testfile
52testrun_compare ${abs_top_builddir}/src/ar -t test.ar << EOF
53testfile
54testfile
55EOF
56testrun ${abs_top_builddir}/src/ar -vx -N 1 test.ar testfile
57diff -u testfile - << EOF
581
59EOF
60testrun ${abs_top_builddir}/src/ar -vx -N 2 test.ar testfile
61diff -u testfile - << EOF
623
63EOF
64
65exit 0
66