forked from canonical/checkbox-provider-ce-oem
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b9675fe
commit 6d0f6be
Showing
9 changed files
with
224 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import unittest | ||
from unittest.mock import patch, mock_open | ||
import json | ||
import env_setup | ||
|
||
|
||
class TestGetConfig(unittest.TestCase): | ||
|
||
@patch('os.path.exists', return_value=True) | ||
def test_valid_config_file(self, mock_exists): | ||
config_path = '/path/to/valid_config.json' | ||
mock_file_content = '{"key": "value"}' | ||
config_file = {} | ||
with patch('builtins.open', mock_open( | ||
read_data=mock_file_content)) as mock_file: | ||
config = env_setup.get_config(config_file, config_path) | ||
|
||
mock_file.assert_called_once_with(config_path) | ||
self.assertEqual(config, {"key": "value"}) | ||
|
||
def test_invalid_config_file(self): | ||
config_path = '/path/to/invalid_config.json' | ||
config_file = { | ||
"test-strict-confinement": { | ||
"channel": "edge", | ||
"plugs": { | ||
"jace-bt-led": { | ||
"gadget": "bt-led", | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
with patch('builtins.open', side_effect=json.JSONDecodeError): | ||
config = env_setup.get_config(config_file, config_path) | ||
|
||
self.assertEqual(config, | ||
{ | ||
"test-strict-confinement": { | ||
"channel": "edge", | ||
"plugs": { | ||
"jace-bt-led": { | ||
"gadget": "bt-led", | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
def test_nonexistent_config_file(self): | ||
config_path = '/path/to/nonexistent_config.json' | ||
config_file = { | ||
"test-strict-confinement": { | ||
"channel": "edge", | ||
"plugs": { | ||
"jace-bt-led": { | ||
"gadget": "bt-led", | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
with patch('builtins.open', side_effect=FileNotFoundError): | ||
config = env_setup.get_config(config_file, config_path) | ||
|
||
self.assertEqual(config, | ||
{ | ||
"test-strict-confinement": { | ||
"channel": "edge", | ||
"plugs": { | ||
"jace-bt-led": { | ||
"gadget": "bt-led", | ||
}, | ||
}, | ||
}, | ||
}) | ||
# Additional checks/assertions if needed | ||
|
||
def test_empty_config_path(self): | ||
config_path = '' | ||
config_file = { | ||
"test-strict-confinement": { | ||
"channel": "edge", | ||
"plugs": { | ||
"jace-bt-led": { | ||
"gadget": "bt-led", | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
config = env_setup.get_config(config_file, config_path) | ||
|
||
self.assertEqual(config, | ||
{ | ||
"test-strict-confinement": { | ||
"channel": "edge", | ||
"plugs": { | ||
"jace-bt-led": { | ||
"gadget": "bt-led", | ||
}, | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
unit: category | ||
id: strict-confinement-mode | ||
_name: Test for strict confinement mode in Uubuntu Core | ||
_name: Test for strict confinement mode in Ubuntu Core |
8 changes: 0 additions & 8 deletions
8
checkbox-provider-ce-oem/units/strict-confinement/env-setup.pxu
This file was deleted.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
checkbox-provider-ce-oem/units/strict-confinement/powermanagement-strict-confinement.pxu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
id: dbus-cold-boot-reboot | ||
category_id: strict-confinement-mode | ||
_summary: Perform cold reboot via dbus | ||
_description: This test will check your system shutdown/booting cycle via dbus command. | ||
unit: job | ||
plugin: shell | ||
environ: STRESS_BOOT_WAKEUP_DELAY RTC_DEVICE_FILE | ||
command: | ||
set -e | ||
rtcwake -d "${RTC_DEVICE_FILE:-rtc0}" -v -m on -s "${STRESS_BOOT_WAKEUP_DELAY:-120}" & | ||
test-strict-confinement.reboot cold | ||
user: root | ||
flags: preserve-locale noreturn autorestart | ||
estimated_duration: 180.0 | ||
imports: | ||
from com.canonical.certification import snap | ||
from com.canonical.certification import lsb | ||
requires: | ||
lsb.distributor_id == 'Ubuntu Core' | ||
snap.name == 'test-strict-confinement' | ||
depends: com.canonical.certification::init-boot-loop-data | ||
|
||
|
||
id: dbus-cold-boot-test | ||
category_id: strict-confinement-mode | ||
_summary: Cold boot system configuration test via dbus | ||
_description: This is a job to check system bootup without error after cold reboot. | ||
unit: job | ||
plugin: shell | ||
environ: LD_LIBRARY_PATH | ||
command: | ||
reboot_check_test.sh -c "$PLAINBOX_SESSION_SHARE/before_reboot" -d "$PLAINBOX_SESSION_SHARE/cold_reboot" -s -f | ||
user: root | ||
flags: preserve-locale | ||
estimated_duration: 1.0 | ||
depends: dbus-cold-boot-reboot | ||
|
||
|
||
id: dbus-warm-boot-reboot | ||
category_id: strict-confinement-mode | ||
_summary: Perform warm reboot via dbus | ||
_description: Perform warm reboot of the system via dbus command. | ||
unit: job | ||
plugin: shell | ||
command: | ||
test-strict-confinement.reboot warm | ||
user: root | ||
flags: preserve-locale noreturn autorestart | ||
estimated_duration: 60s | ||
imports: | ||
from com.canonical.certification import snap | ||
from com.canonical.certification import lsb | ||
requires: | ||
lsb.distributor_id == 'Ubuntu Core' | ||
snap.name == 'test-strict-confinement' | ||
depends: com.canonical.certification::init-boot-loop-data | ||
|
||
|
||
id: dbus-warm-boot-test | ||
category_id: strict-confinement-mode | ||
_summary: Warm boot system configuration test via dbus | ||
_description: This is a job to check system bootup without error after warm reboot. | ||
unit: job | ||
plugin: shell | ||
environ: LD_LIBRARY_PATH | ||
command: | ||
reboot_check_test.sh -c "$PLAINBOX_SESSION_SHARE/before_reboot" -d "$PLAINBOX_SESSION_SHARE/warm_reboot" -s -f | ||
user: root | ||
flags: preserve-locale | ||
estimated_duration: 1.0 | ||
depends: dbus-warm-boot-reboot |
Oops, something went wrong.