-
Notifications
You must be signed in to change notification settings - Fork 78
/
test-output-filenames.sh
executable file
·154 lines (120 loc) · 3.98 KB
/
test-output-filenames.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/sh
#
# test-output-filenames.sh
#
BOARD=bbb
DIR_ONLY=
if [ -n "$1" ] ; then
if [ "$1" = "-h" ] ; then
echo "Usage: test-output-filenames.sh [options]"
echo " -h Show this usage help"
echo " -b <board> Perform test using specified board."
echo " (Defaults to 'bbb')"
echo " -d Run just the directory name test"
echo ""
echo "Test different output filenames"
echo ""
exit 0
fi
if [ "$1" = "-b" ] ; then
shift
BOARD=$1
shift
fi
if [ "$1" = "-d" ] ; then
shift
DIR_ONLY=1
fi
fi
if [ -n "$1" ] ; then
echo "Unrecognized option '$1'"
echo "Use -h for help"
exit 0
fi
echo "Running grabserial on target '$BOARD'"
# get the console device for target board
console_dev="$(ttc info $BOARD -n console_dev)"
ls -ltr | grep -v total | grep -v dir_list >dir_list_before.txt
# Also, use ttc to reboot board
# use ttc to reboot my beaglebone black
if [ -z "$DIR_ONLY" ] ; then
echo "==================================="
echo "Testing with python 2"
echo " 60 second grab, stopping when 'Starting kernel' is seen"
echo " using filename '%'"
echo "==================================="
# do the reboot after grabserial is started
(sleep 1 ; ttc reboot $BOARD) &
# grab data from from that console device (-d ${console_dev},
# skipping the serial port sanity check (-S)
# end either in 60 seconds (-e 60) or when "Starting kernel" is seen
# (-q "Starting kernel")
# send data to graboutput.log (-o {filename}) (filename=%)
# show verbose messages (-v)
./grabserial -v -S -d ${console_dev} -e 60 -t -q "Starting kernel" \
-o %
echo "==== Done with grabserial capture ===="
echo
echo "==================================="
echo "Testing with python 2"
echo " 60 second grab, stopping when 'Starting kernel' is seen"
echo " using filename '%s.log'"
echo "==================================="
(sleep 1 ; ttc reboot $BOARD) &
./grabserial -v -S -d ${console_dev} -e 60 -t -q "Starting kernel" \
-o %s.log
echo "==== Done with grabserial capture ===="
echo
echo "==================================="
echo "Testing with python 2"
echo " 60 second grab, stopping when 'Starting kernel' is seen"
echo " using filename 'mylog-%F_%T.log'"
echo "==================================="
(sleep 1 ; ttc reboot $BOARD) &
./grabserial -v -S -d ${console_dev} -e 60 -t -q "Starting kernel" \
-o mylog-%F_%T.log
echo "==== Done with grabserial capture ===="
echo
echo "==================================="
echo "Testing with python 2"
echo " 120 second grab"
echo " using filename '/tmp/%'", with 20-second log rotations
echo "==================================="
(sleep 1 ; ttc reboot $BOARD) &
./grabserial -v -S -d ${console_dev} -e 120 -t -R 20s \
-o "/tmp/%"
echo "==== Done with grabserial capture ===="
echo
fi
# end of "if [ -z $DIR_ONLY...
echo "==================================="
echo "Testing with python 2"
echo " 60 second grab, stopping when 'Starting kernel' is seen"
echo " using filepath '/tmp/%YYYY/%mm/%dd/mylog-%T.log'"
echo "==================================="
(sleep 1 ; ttc reboot $BOARD) &
./grabserial -v -S -d ${console_dev} -e 60 -t -q "Starting kernel" \
-o "/tmp/%Y/%m/%d/mylog-%T.log"
echo "==== Done with grabserial capture ===="
echo
echo "Checking for output filenames"
echo
ls -ltr | grep -v total | grep -v dir_list >dir_list_after.txt
echo "New files:"
diff -u -B0 dir_list_before.txt dir_list_after.txt | \
grep -v dir_list | grep -v @@
rm dir_list_before.txt dir_list_after.txt
echo
echo "Should have 3 new files, with names like:"
echo "2020-12-02_22:10:06"
echo "1606971316.log"
echo "mylog-2020-12-02_22:10:25.log"
echo
ls -ltr /tmp | tail -n 2 | grep -v total
#ls -ltr /tmp/2023/07/26
echo
echo "Should have 1 new file in /tmp, with a name like:"
echo "2020-12-02_22:12:07"
echo "Should have 1 new file in /tmp/{YYYY}/{mm}/{dd}, like:"
echo "2023/12/02/mylog_22:12:07.log"
echo "Done in test-output-filenames.sh"