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
|
#!/usr/bin/python
import subprocess
import time
import re
def testoutput(TestName,Result):
if (Result==0):
print "***" + TestName + ": pass***"
else:
print "***" + TestName + ": fail***"
def checkforerror(process):
ErrorLevel=0
stdout=""
try:
stdout= subprocess.check_output(process,shell=True,stderr=subprocess.STDOUT)
except subprocess.CalledProcessError, e:
ErrorLevel=-1
stdout=e.output
print process + "\n"+ stdout
return ErrorLevel
def get_stdout(command):
stdout=""
try:
stdout= subprocess.check_output(command,shell=True,stderr=subprocess.STDOUT)
except subprocess.CalledProcessError, e:
stdout=e.output
print command + "\n" + stdout
return stdout
def checkgator():
apt_add=checkforerror('apt-add-repository ppa:linaro-maintainers/arm-ds5 --yes')
apt_get_update=checkforerror('apt-get -y update')
apt_get_install=checkforerror('apt-get -y install gator')
time.sleep(10)
gatord_running = get_stdout('ps ax')
lsmod_output= get_stdout('lsmod')
modout=re.search("gator",lsmod_output)
if (modout>0):
modout=0
daemonout=re.search('\d+:\d+\sgatord', gatord_running)
if (daemonout>0):
daemonout=0
testoutput("AptAdd",apt_add)
testoutput("AptGetUpdate",apt_get_update)
testoutput("AptGetInstall",apt_get_install)
testoutput("ModuleInserted",modout)
testoutput("DaemonRunning",daemonout)
checkgator()
|