Tizen 2.1 base
[external/mawk.git] / test / mawktest
1 #!/bin/sh
2
3 # This is a simple test that a new made mawk seems to
4 # be working OK.
5 # It's certainly not exhaustive, but the last two tests in 
6 # particular use most features.
7 #
8 # It needs to be run from  mawk/test
9 # and mawk needs to be in mawk/test or in PATH
10
11 dat=mawktest.dat
12
13 trap 'echo mawk_test failed ; rm -f temp$$ ; exit 1'  0
14
15 PATH=.:$PATH
16
17 # find out which mawk we're testing
18 mawk -W version
19
20
21 #################################
22 echo
23 echo testing input and field splitting
24
25 mawk -f wc.awk $dat | cmp -s - wc-awk.out || exit
26
27 echo input and field splitting OK
28 #####################################
29
30 echo
31 echo testing regular expression matching
32 mawk -f reg0.awk $dat > temp$$
33 mawk -f reg1.awk $dat >> temp$$
34 mawk -f reg2.awk $dat >> temp$$
35
36 cmp -s  reg-awk.out temp$$ || exit
37
38 echo regular expression matching OK
39 #######################################
40
41 echo
42 if [ -c /dev/full ]; then
43     echo testing checking for write errors
44     # Check for write errors noticed when closing the file
45     mawk '{print}' <full-awk.dat >/dev/full 2>/dev/null && exit
46     # Check for write errors noticed on writing
47     # The file has to be bigger than the buffer size of the libc
48     mawk '{print}' <../scan.c >/dev/full 2>/dev/null && exit
49
50     echo checking for write errors OK
51 else
52     echo "No /dev/full - check for write errors skipped"
53 fi
54
55 #######################################
56
57 echo
58 echo testing arrays and flow of control
59
60 mawk -f wfrq0.awk $dat | cmp -s - wfrq-awk.out || exit
61
62 echo array test OK
63 #################################
64
65 echo
66 echo testing function calls and general stress test
67
68 mawk -f ../examples/decl.awk $dat | cmp -s - decl-awk.out || exit 
69
70 echo general stress test passed
71
72
73 echo
74 echo  tested mawk seems OK
75
76 trap 0
77 rm -f temp$$
78 exit 0