diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 23b96af..ed8c002 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -73,8 +73,9 @@ jobs: run: python util/ghidrathon_configure.py ../tmp/ghidra/ghidra_PUBLIC -d - name: Run tests run: | + pip install packaging ../tmp/ghidra/ghidra_PUBLIC/support/analyzeHeadless ${{ github.workspace }}/../tmp/ghidra test -Import ${{ github.workspace }}/../tmp/ghidra/ghidra_PUBLIC/GPL/DemanglerGnu/os/linux_x86_64/demangler_gnu_v2_24 -PostScript ${{ github.workspace }}/data/python/tests/hello.py -PostScript ${{ github.workspace }}/data/python/tests/runall.py > ../tmp/log.txt - name: Check tests run: | - python -c "import pathlib, sys;log_text=pathlib.Path('../tmp/log.txt').read_text(encoding='utf-8');print(log_text);sys.exit(0 if 'runall.py called exit with code -1' not in log_text else -1)" + python -c "import pathlib, sys;log_text=pathlib.Path('../tmp/log.txt').read_text(encoding='utf-8');print(log_text);sys.exit(0 if 'runall.py called exit with code 0' in log_text else -1)" python -c "import pathlib, sys; sys.exit(0 if pathlib.Path('hello.txt').exists() else -1)" diff --git a/data/python/tests/test_pythonenv.py b/data/python/tests/test_pythonenv.py new file mode 100644 index 0000000..69d21a1 --- /dev/null +++ b/data/python/tests/test_pythonenv.py @@ -0,0 +1,22 @@ +# Copyright (C) 2024 Mandiant, Inc. All Rights Reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: [package root]/LICENSE.txt +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and limitations under the License. + +"""Unit tests to verify Python environment + +Note: you must run these tests from the Ghidra script manager or headless mode +""" + +import unittest + + +class TestPythonEnv(unittest.TestCase): + def test_packaging_tags(self): + # https://github.com/mandiant/Ghidrathon/issues/62 + from packaging.tags import platform_tags + + self.assertIsInstance(tuple(platform_tags()), tuple)