Skip to content

Commit

Permalink
use test -e to check if file exists
Browse files Browse the repository at this point in the history
Signed-off-by: pengshanyu <[email protected]>
  • Loading branch information
pengshanyu committed Aug 7, 2024
1 parent 7afe651 commit 496f62a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
6 changes: 3 additions & 3 deletions tests/ffi/dev-mem_not_present/PURPOSE
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Verifies that /dev/mem is not present in QM partition.

This test execute `ls -l /dev/mem` (no other input) in QM partition:
podman exec -t qm bash -c "ls -l /dev/mem"
This test execute `test -e /dev/mem &>/dev/null` in QM partition, no other input.
podman exec qm test -e /dev/mem &>/dev/null

Expected result:
out: [ INFO ] PASS: /dev/mem is not present in QM partition.
out: [ INFO ] PASS: check_dev-mem_not_present: As expected, /dev/mem is not present in QM partition.

Results location:
/plans/e2e/ffi/report/default-0/junit.xml
15 changes: 6 additions & 9 deletions tests/ffi/dev-mem_not_present/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@
. ../../e2e/lib/utils

check_dev-mem_not_present(){
expected_result="ls: cannot access '/dev/mem': No such file or directory"
return_from_cmd=$(podman exec -t qm bash -c "ls -l /dev/mem")

# Check /dev/mem is not present in QM partition
if [[ $? != "0" && "${return_from_cmd}" == "${expected_result}"* ]]; then
info_message "PASS: check_dev-mem_not_present: /dev/mem is not present in QM partition."
exit 0
else
info_message "Command 'ls -l /dev/mem' returns from QM partition: ${return_from_cmd}"
info_message "FAIL: check_dev-mem_not_present: Check /dev/mem is not present in QM partition failed."
if podman exec qm test -e /dev/mem &>/dev/null; then
info_message "Found /dev/mem in QM partition: $(podman exec -t qm ls -l /dev/mem)"
info_message "FAIL: check_dev-mem_not_present: Check for /dev/mem in QM partition failed, it should not present."
exit 1
else
info_message "PASS: check_dev-mem_not_present: As expected, /dev/mem is not present in QM partition."
exit 0
fi
}

Expand Down

0 comments on commit 496f62a

Please sign in to comment.