cleanup
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
|
||||
folder_path = os.path.abspath(os.path.join("components", "system_tests"))
|
||||
if folder_path not in sys.path:
|
||||
sys.path.append(folder_path)
|
||||
|
||||
from scan_serial import ESP32Runner
|
||||
|
||||
def test_nvm_initialize():
|
||||
runner = ESP32Runner(mode="SIM", port="COM9")
|
||||
runner.start()
|
||||
print("--- QEMU Runner Started ---", flush=True)
|
||||
try:
|
||||
start_time = time.time()
|
||||
while time.time() - start_time < 30:
|
||||
line = runner.get_line(timeout=1.0)
|
||||
if line:
|
||||
print(line, flush=True)
|
||||
if "NVM driver initialized successfully" in line:
|
||||
print("SUCCESS CRITERIA MET!", flush=True)
|
||||
return 0
|
||||
if runner.process.poll() is not None:
|
||||
print(f"Process exited with code: {runner.process.returncode}", flush=True)
|
||||
return 1
|
||||
finally:
|
||||
runner.stop()
|
||||
print("Done.", flush=True)
|
||||
return 1
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit_code = test_nvm_initialize()
|
||||
sys.exit(exit_code)
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<test_scenario>
|
||||
<!-- The configuration for the test environment. -->
|
||||
<!-- Available configurations: SIMULATE, HIL -->
|
||||
<config>SIMULATE</config>
|
||||
|
||||
<test_case>
|
||||
<test_case_id>NVM_INIT_TEST</test_case_id>
|
||||
<!-- The main command that executes the test itself. -->
|
||||
<test_exec>python components/drivers/nvm/test/nvm_init_test.py</test_exec>
|
||||
</test_case>
|
||||
|
||||
|
||||
</test_scenario>
|
||||
47
1 software design/components/drivers/nvm/test/test_nvm.cpp
Normal file
47
1 software design/components/drivers/nvm/test/test_nvm.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @file test_nvm.cpp
|
||||
* @brief Unit tests for NVM driver component
|
||||
* @author Mahmoud Elmohtady
|
||||
* @company Nabd solutions - ASF
|
||||
* @copyright Copyright (c) 2025
|
||||
*/
|
||||
|
||||
#include "unity.h"
|
||||
#include "nvm.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
}
|
||||
|
||||
void test_nvm_initialize(void)
|
||||
{
|
||||
NvmDriver nvm;
|
||||
bool result = nvm.initialize();
|
||||
TEST_ASSERT_TRUE(result);
|
||||
TEST_ASSERT_TRUE(nvm.isInitialized());
|
||||
}
|
||||
|
||||
void test_nvm_read_write(void)
|
||||
{
|
||||
NvmDriver nvm;
|
||||
nvm.initialize();
|
||||
|
||||
uint32_t writeValue = 12345;
|
||||
size_t length = sizeof(writeValue);
|
||||
|
||||
NvmResult result = nvm.write("test_key", &writeValue, length);
|
||||
TEST_ASSERT_EQUAL(NvmResult::OK, result);
|
||||
|
||||
uint32_t readValue = 0;
|
||||
result = nvm.read("test_key", &readValue, &length);
|
||||
TEST_ASSERT_EQUAL(NvmResult::OK, result);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
Reference in New Issue
Block a user