Skip to content

Commit

Permalink
Merge pull request #671 from airtower-luna/find-python-binary
Browse files Browse the repository at this point in the history
Find python binary dynamically
  • Loading branch information
tomato42 committed Jun 15, 2020
2 parents f9d4439 + 848c36e commit 6a36513
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 25 deletions.
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.PHONY : default
PYTHON=$(or $(shell which python3),$(shell which python))
default:
@echo "To install run \"./setup.py install\" or \"make install\""
@echo "To test sanity of code run \"make test\""
Expand All @@ -14,7 +15,7 @@ clean:

.PHONY : install
install:
./setup.py install
"$(PYTHON)" setup.py install

.PHONY : docs
docs:
Expand All @@ -26,11 +27,11 @@ test: docs
coverage3 report -m
coverage3 xml
coverage3 html
python tests/verify-scripts-json.py tests/tlslite-ng.json tests/tlslite-ng-random-subset.json
"$(PYTHON)" tests/verify-scripts-json.py tests/tlslite-ng.json tests/tlslite-ng-random-subset.json
pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" tlsfuzzer > pylint_report.txt || :
diff-quality --violations=pylint --fail-under=90 pylint_report.txt
diff-cover --fail-under=90 coverage.xml

test-scripts:
python tests/verify-scripts-json.py tests/tlslite-ng.json tests/tlslite-ng-random-subset.json
python tests/scripts_retention.py tests/tlslite-ng.json `which tls.py` 1850
"$(PYTHON)" tests/verify-scripts-json.py tests/tlslite-ng.json tests/tlslite-ng-random-subset.json
"$(PYTHON)" tests/scripts_retention.py tests/tlslite-ng.json ../tlslite-ng/scripts/tls.py 1850
6 changes: 5 additions & 1 deletion tests/scripts_retention.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def run_clients(tests, common_args, srv, expected_size):
script = params["name"]
logger.info("{0}:started".format(script))
start_time = time.time()
proc_args = ['python', '-u',
proc_args = [sys.executable, '-u',
'scripts/{0}'.format(script)]
arguments = params.get("arguments", [])
arguments = [expected_size if arg == "{expected_size}" else arg for
Expand Down Expand Up @@ -196,6 +196,10 @@ def run_with_json(config_file, srv_path, expected_size):

for srv_conf in config:
command = srv_conf["server_command"]
for number, value in enumerate(command):
if value == '{python}':
command[number] = sys.executable
break
for number, value in enumerate(command):
if value == "{command}":
command[number] = srv_path
Expand Down
20 changes: 10 additions & 10 deletions tests/tlslite-ng-random-subset.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
{"server_command": ["python", "-u", "{command}", "server",
{"server_command": ["{python}", "-u", "{command}", "server",
"-k", "tests/serverX509Key.pem",
"-c", "tests/serverX509Cert.pem",
"--cipherlist", "chacha20-poly1305",
Expand Down Expand Up @@ -324,7 +324,7 @@
{"name" : "test-zero-length-data.py"}
]
},
{"server_command": ["python", "-u", "{command}", "server",
{"server_command": ["{python}", "-u", "{command}", "server",
"-k", "tests/serverX509Key.pem",
"-c", "tests/serverX509Cert.pem",
"--reqcert", "localhost:4433"],
Expand Down Expand Up @@ -374,7 +374,7 @@
}
]
},
{"server_command": ["python", "-u", "{command}", "server",
{"server_command": ["{python}", "-u", "{command}", "server",
"-k", "tests/serverX509Key.pem",
"-c", "tests/serverX509Cert.pem",
"--ssl3",
Expand All @@ -392,7 +392,7 @@
{"name" : "test-SSLv3-padding.py"}
]
},
{"server_command": ["python", "-u", "{command}", "server",
{"server_command": ["{python}", "-u", "{command}", "server",
"--psk", "aa",
"--psk-ident", "test",
"localhost:4433"],
Expand All @@ -405,7 +405,7 @@
{"name" : "test-tls13-psk_dhe_ke.py"}
]
},
{"server_command": ["python", "-u", "{command}", "server",
{"server_command": ["{python}", "-u", "{command}", "server",
"--psk", "aa",
"--psk-ident", "test",
"--psk-sha384",
Expand All @@ -420,7 +420,7 @@
{"name" : "test-tls13-psk_dhe_ke.py"}
]
},
{"server_command": ["python", "-u", "{command}", "server",
{"server_command": ["{python}", "-u", "{command}", "server",
"-k", "tests/serverRSAPSSKey.pem",
"-c", "tests/serverRSAPSSCert.pem",
"localhost:4433"],
Expand All @@ -437,7 +437,7 @@
}
]
},
{"server_command": ["python", "-u", "{command}", "server",
{"server_command": ["{python}", "-u", "{command}", "server",
"-k", "tests/serverX509Key.pem",
"-c", "tests/serverX509Cert.pem",
"--max-ver", "tls1.2",
Expand All @@ -457,7 +457,7 @@
{"name" : "test-tls13-non-support.py"}
]
},
{"server_command": ["python", "-u", "{command}", "server",
{"server_command": ["{python}", "-u", "{command}", "server",
"-k", "tests/serverX509Key.pem",
"-c", "tests/serverX509Cert.pem",
"--request-pha",
Expand All @@ -472,7 +472,7 @@
}
]
},
{"server_command": ["python", "-u", "{command}", "server",
{"server_command": ["{python}", "-u", "{command}", "server",
"-k", "tests/serverX509Key.pem",
"-c", "tests/serverX509Cert.pem",
"--require-pha",
Expand All @@ -489,7 +489,7 @@
}
]
},
{"server_command": ["python", "-u", "{command}", "server",
{"server_command": ["{python}", "-u", "{command}", "server",
"-c", "tests/serverECCert.pem",
"-k", "tests/serverECKey.pem",
"-c", "tests/serverP384ECCert.pem",
Expand Down
20 changes: 10 additions & 10 deletions tests/tlslite-ng.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
{"server_command": ["python", "-u", "{command}", "server",
{"server_command": ["{python}", "-u", "{command}", "server",
"-k", "tests/serverX509Key.pem",
"-c", "tests/serverX509Cert.pem",
"--cipherlist", "chacha20-poly1305",
Expand Down Expand Up @@ -320,7 +320,7 @@
{"name" : "test-zero-length-data.py"}
]
},
{"server_command": ["python", "-u", "{command}", "server",
{"server_command": ["{python}", "-u", "{command}", "server",
"-k", "tests/serverX509Key.pem",
"-c", "tests/serverX509Cert.pem",
"--reqcert", "localhost:4433"],
Expand Down Expand Up @@ -370,7 +370,7 @@
}
]
},
{"server_command": ["python", "-u", "{command}", "server",
{"server_command": ["{python}", "-u", "{command}", "server",
"-k", "tests/serverX509Key.pem",
"-c", "tests/serverX509Cert.pem",
"--ssl3",
Expand All @@ -386,7 +386,7 @@
{"name" : "test-SSLv3-padding.py"}
]
},
{"server_command": ["python", "-u", "{command}", "server",
{"server_command": ["{python}", "-u", "{command}", "server",
"--psk", "aa",
"--psk-ident", "test",
"localhost:4433"],
Expand All @@ -399,7 +399,7 @@
{"name" : "test-tls13-psk_dhe_ke.py"}
]
},
{"server_command": ["python", "-u", "{command}", "server",
{"server_command": ["{python}", "-u", "{command}", "server",
"--psk", "aa",
"--psk-ident", "test",
"--psk-sha384",
Expand All @@ -414,7 +414,7 @@
{"name" : "test-tls13-psk_dhe_ke.py"}
]
},
{"server_command": ["python", "-u", "{command}", "server",
{"server_command": ["{python}", "-u", "{command}", "server",
"-k", "tests/serverRSAPSSKey.pem",
"-c", "tests/serverRSAPSSCert.pem",
"localhost:4433"],
Expand All @@ -431,7 +431,7 @@
}
]
},
{"server_command": ["python", "-u", "{command}", "server",
{"server_command": ["{python}", "-u", "{command}", "server",
"-k", "tests/serverX509Key.pem",
"-c", "tests/serverX509Cert.pem",
"--max-ver", "tls1.2",
Expand All @@ -451,7 +451,7 @@
{"name" : "test-tls13-non-support.py"}
]
},
{"server_command": ["python", "-u", "{command}", "server",
{"server_command": ["{python}", "-u", "{command}", "server",
"-k", "tests/serverX509Key.pem",
"-c", "tests/serverX509Cert.pem",
"--request-pha",
Expand All @@ -466,7 +466,7 @@
}
]
},
{"server_command": ["python", "-u", "{command}", "server",
{"server_command": ["{python}", "-u", "{command}", "server",
"-k", "tests/serverX509Key.pem",
"-c", "tests/serverX509Cert.pem",
"--require-pha",
Expand All @@ -483,7 +483,7 @@
}
]
},
{"server_command": ["python", "-u", "{command}", "server",
{"server_command": ["{python}", "-u", "{command}", "server",
"-k", "tests/serverECKey.pem",
"-c", "tests/serverECCert.pem",
"--cipherlist", "chacha20-poly1305",
Expand Down

0 comments on commit 6a36513

Please sign in to comment.