Skip to content

Commit

Permalink
feat: add nested path tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zjregee committed Aug 24, 2024
1 parent 738e439 commit 3101e2e
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 109 deletions.
7 changes: 0 additions & 7 deletions .github/scripts/build_and_run_ovfs.sh

This file was deleted.

31 changes: 27 additions & 4 deletions .github/scripts/path_behavior_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os
from pathlib import Path

TEST_POINT = "/mnt"
TEST_PRESET_PATHS = [
("./behavior_test_judge.py", True),
("./build_and_run_ovfs.sh", True),
("./file_behavior_test.py", True),
("./image.img", True),
("./install_and_run_vm.sh", True),
Expand All @@ -13,6 +13,17 @@
("./ubuntu-20.04.6-live-server-amd64.iso", True),
("./user-data", True),
]
TEST_NESTED_PATHS = [
("./dir1", False),
("./dir2", False),
("./dir3", False),
("./dir3/dir4", False),
("./dir3/dir5", False),
("./dir3/file3", True),
("./dir3/file4", True),
("./file1", True),
("./file2", True),
]

def list_paths():
walked_entries = []
Expand All @@ -24,11 +35,23 @@ def list_paths():
walked_entries.append((os.path.join(rel_dir, filename), True))
return walked_entries

def create_paths():
for path, is_file in TEST_NESTED_PATHS:
if is_file:
with open(Path(TEST_POINT) / path, "w") as f:
f.write("This is a file.")
else:
os.makedirs(Path(TEST_POINT) / path, exist_ok=False)

def test_path():
paths = list_paths()
paths.sort()
TEST_PRESET_PATHS.sort()
assert paths == TEST_PRESET_PATHS
assert paths.sort() == TEST_PRESET_PATHS.sort()

def test_nested_path():
create_paths()
paths = list_paths()
assert paths.sort() == (TEST_NESTED_PATHS + TEST_PRESET_PATHS).sort()

if __name__ == "__main__":
test_path()
test_nested_path()
8 changes: 5 additions & 3 deletions .github/workflows/behavior_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ jobs:
- uses: actions/checkout@v4

- name: Run Behavior Test
env:
KIND: fs
ROOT: .github/scripts
run: |
chmod +x ./build_and_run_ovfs.sh
cargo run --manifest-path ../../Cargo.toml --release &
chmod +x ./install_and_run_vm.sh
nohup ./build_and_run_ovfs.sh &
nohup ./install_and_run_vm.sh &
./install_and_run_vm.sh &
pip install paramiko
python behavior_test_judge.py
working-directory: .github/scripts
25 changes: 0 additions & 25 deletions scripts/scripts.sh

This file was deleted.

7 changes: 0 additions & 7 deletions scripts/test.sh

This file was deleted.

Loading

0 comments on commit 3101e2e

Please sign in to comment.