Skip to content

Commit 20cb00a

Browse files
authored
add unit test for #62 (#89)
1 parent 01bf21b commit 20cb00a

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

.github/workflows/tests.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ jobs:
7373
run: python util/ghidrathon_configure.py ../tmp/ghidra/ghidra_PUBLIC -d
7474
- name: Run tests
7575
run: |
76+
pip install packaging
7677
../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
7778
- name: Check tests
7879
run: |
79-
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)"
80+
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)"
8081
python -c "import pathlib, sys; sys.exit(0 if pathlib.Path('hello.txt').exists() else -1)"

data/python/tests/test_pythonenv.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright (C) 2024 Mandiant, Inc. All Rights Reserved.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at: [package root]/LICENSE.txt
5+
# Unless required by applicable law or agreed to in writing, software distributed under the License
6+
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7+
# See the License for the specific language governing permissions and limitations under the License.
8+
9+
"""Unit tests to verify Python environment
10+
11+
Note: you must run these tests from the Ghidra script manager or headless mode
12+
"""
13+
14+
import unittest
15+
16+
17+
class TestPythonEnv(unittest.TestCase):
18+
def test_packaging_tags(self):
19+
# https://github.com/mandiant/Ghidrathon/issues/62
20+
from packaging.tags import platform_tags
21+
22+
self.assertIsInstance(tuple(platform_tags()), tuple)

0 commit comments

Comments
 (0)