]> git.proxmox.com Git - swtpm.git/commitdiff
tests: Make python test code independent of python 2 or 3
authorStefan Berger <stefanb@linux.vnet.ibm.com>
Fri, 3 Aug 2018 22:58:36 +0000 (18:58 -0400)
committerStefan Berger <stefanb@linux.vnet.ibm.com>
Tue, 7 Aug 2018 16:19:47 +0000 (12:19 -0400)
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
tests/test_clientfds.py
tests/test_ctrlchannel3
tests/test_setdatafd.py

index 289da09e7963c6519a183b147ab05b2d3537ed7b..3220bfbb6fe3619bdbadf6265a72f27c5fe0b4df 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 
 import os
 import sys
@@ -42,7 +42,11 @@ def spawn_swtpm():
     cmd += " --pid file=" + pidfile + " --tpmstate dir=" + tpmpath
     print("Running child cmd: %s" % cmd)
     try:
-        child = subprocess.Popen(cmd.split())
+        if sys.version_info[0] >= 3:
+            child = subprocess.Popen(cmd.split(),
+                                     pass_fds=[_fd.fileno(), _ctrlfd.fileno()])
+        else:
+            child = subprocess.Popen(cmd.split())
     except OSError as err:
         print("OS error: %d" % err.errno)
         return False
@@ -94,7 +98,7 @@ if __name__ == "__main__":
         else:
             res = 0
     except:
-        print "__Exception: ", sys.exc_info()
+        print("__Exception: ", sys.exc_info())
         res = -1
 
     if child:
index 06710d030de6a39be924311d868373d310d8d639..f0bf368cf30ae843ad55021c4664bde81e5a104d 100755 (executable)
@@ -45,7 +45,7 @@ if wait_for_file $PID_FILE 3; then
        exit 1
 fi
 
-LOG=$(SOCK_PATH=$SWTPM_CTRL_UNIX_PATH exec python $TESTDIR/test_setdatafd.py)
+LOG=$(SOCK_PATH=$SWTPM_CTRL_UNIX_PATH exec $TESTDIR/test_setdatafd.py)
 res=$?
 
 if [ $res -ne 0 ]; then
index 70b4c394d351aefe26645c87219e23647c45e2ed..e51ace89c7cd2075a5211a3312eeb5f9ec1ea771 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 
 import os
 import sys