add manifest file, add findunittest command in script
[platform/core/system/swap-manager.git] / daemon / da_command
1 #!/bin/bash
2
3 KILL=/usr/bin/killall
4 MANAGER=/usr/bin/da_manager
5 EVENT=/usr/bin/da_event
6 FIND=/usr/bin/find
7 GETAPPINSTALLPATH="/usr/bin/pkgcmd -a"
8
9 print_usage()
10 {
11         echo "usage: da_command [options]"
12         echo "Options:"
13         echo "killmanager               terminate da_manager"
14         echo "killapp apppath           terminate application"
15         echo "runmanager                execute da_manager"
16         echo "runevent record|play      execute da_event"
17         echo "findunittest              find unittest project"
18 }
19
20 kill_manager()
21 {
22         $KILL $MANAGER
23 }
24
25 kill_app()
26 {
27         $KILL $APPPATH
28 }
29
30 run_manager()
31 {
32         $MANAGER
33 }
34
35 run_event()
36 {
37         case "$EVENTOPTION" in
38                 record)
39                         EVENTMODE="-r"
40                         ;;
41                 play)
42                         EVENTMODE="-s"
43                         ;;
44                 *)
45                         echo "Invalid event option!"
46                         print_usage
47                         exit 1
48                         ;;
49         esac
50
51         $EVENT $EVENTMODE
52 }
53
54 find_unittest()
55 {
56         $FIND `$GETAPPINSTALLPATH | awk '{if (FNR==1) printf $NF}'` -name *.unittest
57 }
58
59 process_list()
60 {
61         ps -eo pid,cmd
62 }
63
64
65 if test $# -gt 2 -o $# -lt 1; then
66         print_usage
67         exit 1
68 fi
69
70 if test -n "$2"; then
71         case "$1" in
72                 runevent)
73                         EVENTOPTION=$2
74                         ;;
75                 killapp)
76                         APPPATH=$2
77                         ;;
78                 *)
79                         print_usage
80                         exit 1
81                         ;;
82         esac
83 fi
84
85 case "$1" in
86         killmanager)
87                 kill_manager
88                 ;;
89         killapp)
90                 kill_app
91                 ;;
92         runmanager)
93                 run_manager
94                 ;;
95         runevent)
96                 run_event
97                 ;;
98         findunittest)
99                 find_unittest
100                 ;;
101         process)
102                 process_list
103                 ;;
104         *)
105                 echo "Unknown option!"
106                 print_usage
107                 ;;
108 esac
109