forked from embedded2016/unit-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-bubble.sh
executable file
·52 lines (39 loc) · 1.14 KB
/
test-bubble.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
#!/bin/bash
echo 'b main' >> _tmp.gdb
echo 'r' >> _tmp.gdb
echo 'source scripts/create_list.gdb' >> _tmp.gdb
echo 'source scripts/print_list.gdb' >> _tmp.gdb
echo 'source scripts/free_list.gdb' >> _tmp.gdb
echo 'set $head = (List**)malloc(sizeof(List*))' >> _tmp.gdb
echo 'set logging file '$2>>_tmp.gdb
echo ' '>>$2
exec < $1
while (read var)
do
read var
list_length=$var
echo 'create_list (*($head)) '$list_length >> _tmp.gdb
read var
list_value=($var)
echo 'set $_head = (*($head))' >> _tmp.gdb
for value in "${list_value[@]}"
do
echo 'p $_head->value = '$value >> _tmp.gdb
echo 'p $_head = $_head->next' >> _tmp.gdb
done
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 'p bubble_sort($head)' >> _tmp.gdb
echo 'set logging on' >> _tmp.gdb
echo 'p "new_list"' >> _tmp.gdb
echo 'printf_list (*($head))' >> _tmp.gdb
echo 'set logging off' >> _tmp.gdb
echo 'free_list (*($head))' >> _tmp.gdb
done
echo 'q' >> _tmp.gdb
echo 'y' >> _tmp.gdb
gdb -q -x _tmp.gdb bin-bubble >>/dev/null
rm _tmp.gdb