pf_route6(): one more __sdt_used annotation
[freebsd/src.git] / usr.bin / lorder / tests / lorder_test.sh
bloba4276b2dcfe666bf21ff3641a4ce20fa8e1ad4d4
2 # Copyright (c) 2024 Klara, Inc.
4 # SPDX-License-Identifier: BSD-2-Clause
7 atf_test_case noargs
8 noargs_head() {
9 atf_set descr "No arguments"
11 noargs_body() {
12 atf_check -s exit:1 -e match:"^usage:" \
13 lorder
16 atf_test_case onearg
17 onearg_head() {
18 atf_set descr "One argument"
20 onearg_body() {
21 echo "void a(void) { }" >a.c
22 cc -o a.o -c a.c
23 echo "a.o a.o" >output
24 atf_check -o file:output \
25 lorder *.o
28 atf_test_case dashdash
29 dashdash_head() {
30 atf_set descr "One argument"
32 dashdash_body() {
33 echo "void a(void) { }" >a.c
34 cc -o a.o -c a.c
35 echo "a.o a.o" >output
36 atf_check -o file:output \
37 lorder -- *.o
40 atf_test_case nonexistent
41 nonexistent_head() {
42 atf_set descr "Nonexistent file"
44 nonexistent_body() {
45 atf_check -s not-exit:0 -e match:"No such file" -o empty \
46 lorder nonexistent.o
49 atf_test_case invalid
50 invalid_head() {
51 atf_set descr "Invalid file"
53 invalid_body() {
54 echo "not an object file" >invalid.o
55 atf_check -s not-exit:0 -e match:"not recognized" -o empty \
56 lorder invalid.o
59 atf_test_case objects
60 objects_head() {
61 atf_set descr "Order objects"
63 objects_body() {
64 echo "void a(void) { }" >a.c
65 echo "void a(void); void b(void) { a(); }" >b.c
66 echo "void b(void); void c(void) { b(); }" >c.c
67 for n in a b c ; do
68 cc -o $n.o -c $n.c
69 echo "$n.o $n.o"
70 done >output
71 echo "b.o a.o" >>output
72 echo "c.o b.o" >>output
73 atf_check -o file:output \
74 lorder *.o
77 atf_test_case archives
78 archives_head() {
79 atf_set descr "Order archives"
81 archives_body() {
82 echo "void a(void) { }" >a.c
83 echo "void a(void); void b(void) { a(); }" >b.c
84 echo "void b(void); void c(void) { b(); }" >c.c
85 echo "void e(void); void d(void) { e(); }" >d.c
86 echo "void d(void); void e(void) { d(); }" >e.c
87 for n in a b c d e ; do
88 cc -o $n.o -c $n.c
89 done
90 for n in a b c ; do
91 ar -crs $n.a $n.o
92 echo "$n.a $n.a"
93 done >output
94 ar -crs z.a d.o e.o
95 echo "z.a z.a" >>output
96 echo "b.a a.a" >>output
97 echo "c.a b.a" >>output
98 atf_check -o file:output \
99 lorder *.a
102 atf_init_test_cases()
104 atf_add_test_case noargs
105 atf_add_test_case onearg
106 atf_add_test_case dashdash
107 atf_add_test_case nonexistent
108 atf_add_test_case invalid
109 atf_add_test_case objects
110 atf_add_test_case archives