forked from embedded2016/unit-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-swap.sh
executable file
·46 lines (37 loc) · 1.11 KB
/
test-swap.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
#!/bin/bash
echo b main >> _tmp.gdb
echo r >> _tmp.gdb
echo source scripts/create_list.gdb >> _tmp.gdb
echo source scripts/printf_list.gdb >> _tmp.gdb
echo source scripts/find_node_address.gdb >> _tmp.gdb
echo 'set $head = (List*)0' >> _tmp.gdb
echo 'set $node1 = (List*)0' >> _tmp.gdb
echo 'set $node2 = (List*)0' >> _tmp.gdb
exec < $1
read var
echo 'create_list $head' $var >> _tmp.gdb
exec < $1
echo ' '>>$2
echo 'set logging file '$2 >> _tmp.gdb
while (read var)
do
read var
node_1=$var
read var
node_2=$var
echo 'set logging on' >> _tmp.gdb
echo 'p "test begin"' >> _tmp.gdb
echo 'p "old_list"' >> _tmp.gdb
echo 'printf_list $head' >> _tmp.gdb
echo 'set logging off' >> _tmp.gdb
echo 'find_node_address $head '$node_1' $node1' >> _tmp.gdb
echo 'find_node_address $head '$node_2' $node2' >> _tmp.gdb
echo 'p $head = swap($head,$node1,$node2)' >> _tmp.gdb
echo 'set logging on' >> _tmp.gdb
echo 'p "change '$node_1' '$node_2'"' >> _tmp.gdb
echo 'p "new_list"' >> _tmp.gdb
echo 'printf_list $head' >> _tmp.gdb
echo 'set logging off' >> _tmp.gdb
done
gdb -q -x _tmp.gdb bin-swap >> /dev/null
rm _tmp.gdb