]> git.saurik.com Git - apple/xnu.git/blob - libkern/kxld/tests/loadtest.py
xnu-1504.15.3.tar.gz
[apple/xnu.git] / libkern / kxld / tests / loadtest.py
1 #!/usr/bin/env python
2
3 import sys
4 from subprocess import call, Popen, PIPE
5
6 kexts = []
7 pipe = Popen("/usr/sbin/kextfind \( -l -and -x -and -arch i386 \)", shell=True, stdout=PIPE).stdout
8
9 line = pipe.readline()
10 while line:
11 kexts.append(line.strip())
12 line = pipe.readline()
13
14 NULL = open("/dev/null")
15
16 for kext in kexts:
17 try:
18 print "Processing", kext
19 #cmd = "/sbin/kextload -ns /tmp/syms \"%s\"" % kext
20 cmd = "/sbin/kextload \"%s\"" % kext
21 kextload = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE)
22 for i in range(20):
23 kextload.stdin.write("0x1000\n");
24 retcode = kextload.wait()
25 if retcode < 0:
26 print >>sys.stderr, "*** kextload of %s was terminated by signal %d" % (kext, -retcode)
27 elif retcode > 0:
28 print >>sys.stderr, "*** kextload of %s failed with return code %d" % (kext, retcode)
29 except OSError, e:
30 print >>sys.stderr, "Execution failed:", e
31 sys.exit(1)
32