GNU Linux-libre 4.19.264-gnu1
[releases.git] / tools / testing / selftests / android / ion / ion_test.sh
1 #!/bin/bash
2
3 heapsize=4096
4 TCID="ion_test.sh"
5 errcode=0
6
7 # Kselftest framework requirement - SKIP code is 4.
8 ksft_skip=4
9
10 run_test()
11 {
12         heaptype=$1
13         ./ionapp_export -i $heaptype -s $heapsize &
14         sleep 1
15         ./ionapp_import
16         if [ $? -ne 0 ]; then
17                 echo "$TCID: heap_type: $heaptype - [FAIL]"
18                 errcode=1
19         else
20                 echo "$TCID: heap_type: $heaptype - [PASS]"
21         fi
22         sleep 1
23         echo ""
24 }
25
26 check_root()
27 {
28         uid=$(id -u)
29         if [ $uid -ne 0 ]; then
30                 echo $TCID: must be run as root >&2
31                 exit $ksft_skip
32         fi
33 }
34
35 check_device()
36 {
37         DEVICE=/dev/ion
38         if [ ! -e $DEVICE ]; then
39                 echo $TCID: No $DEVICE device found >&2
40                 echo $TCID: May be CONFIG_ION is not set >&2
41                 exit $ksft_skip
42         fi
43 }
44
45 main_function()
46 {
47         check_device
48         check_root
49
50         # ION_SYSTEM_HEAP TEST
51         run_test 0
52         # ION_SYSTEM_CONTIG_HEAP TEST
53         run_test 1
54 }
55
56 main_function
57 echo "$TCID: done"
58 exit $errcode