Skip to content

Commit

Permalink
psh: touch tests improvements
Browse files Browse the repository at this point in the history
JIRA CI-336
  • Loading branch information
mateusz-bloch committed Sep 29, 2023
1 parent 3c88d08 commit fadfb82
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion psh/test-autocompletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#
import psh.tools.psh as psh


TAB = '\x09'
ENTER = '\x0D'

Expand Down Expand Up @@ -87,3 +86,4 @@ def harness(p):

# TODO Tests: backspace handling, symlink handling
# TODO cleanup folders after tests

11 changes: 7 additions & 4 deletions psh/test-touch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
#

import psh.tools.psh as psh
import trunner.config as config
import trunner.ctx as ctx
from psh.tools.randwrapper import TestRandom
from psh.tools.common import (CHARS, assert_present, assert_file_created, assert_dir_created,
assert_random_files, get_rand_strings, create_testdir, assert_mtime)
assert_random_files, get_rand_strings, create_testdir,
assert_mtime, assert_deleted_rec)


ROOT_TEST_DIR = 'test_touch_dir'
Expand All @@ -26,7 +27,7 @@ def assert_executable(p):
# psh is the example of executable which exists in file system
msg = "Prompt hasn't been seen after the executable touch: /usr/bin/hello"
date = psh.date(p)
if config.CURRENT_TARGET in config.SYSEXEC_TARGETS:
if not ctx.target.rootfs:
psh.assert_cmd(p, 'touch /syspage/psh', result='success', msg=msg)
assert_mtime(p, {'psh': date}, '/syspage')
else:
Expand Down Expand Up @@ -75,7 +76,7 @@ def assert_existing_dirs(p):
# we assume that syspage directory exists on syspage targets and bin directory exists on root-fs targets
msg = "Prompt hasn't been seen after the executable touch: /usr/bin/hello"
date = psh.date(p)
if config.CURRENT_TARGET in config.SYSEXEC_TARGETS:
if not ctx.target.rootfs:
psh.assert_cmd(p, 'touch /syspage/', result='success', msg=msg)
assert_mtime(p, {'syspage': date}, '/')
else:
Expand Down Expand Up @@ -104,3 +105,5 @@ def harness(p):

assert_devices(p)
assert_executable(p)

assert_deleted_rec(p, ROOT_TEST_DIR)
4 changes: 0 additions & 4 deletions psh/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,10 @@ test:
harness: test-mkdir.py

- name: touch
# TODO touch of netsocket and pf fails...
harness: test-touch.py
ignore: True

- name: touch-rootfs
harness: test-touch-rootfs.py
# temporary disabled because of the following issue: https://github.com/phoenix-rtos/phoenix-rtos-project/issues/621
ignore: true
targets:
exclude: [armv7m7-imxrt106x-evk, armv7m7-imxrt117x-evk, armv7m4-stm32l4x6-nucleo]

Expand Down
2 changes: 1 addition & 1 deletion psh/tools/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def assert_mtime(p, datetimes: Dict[str, datetime], dir=''):
date = date.replace(year=target_datetime.year, second=target_datetime.second)

# to prevent failed assertion when typing date in 00:59 and touch in 01:00
if date - target_datetime == timedelta(minutes=1):
if abs(date - target_datetime) == timedelta(minutes=1):
date = target_datetime

assert date == target_datetime, "".join((
Expand Down

0 comments on commit fadfb82

Please sign in to comment.