This guide provides instructions on how to run and add GUIX and GUIX Studio regression tests, along with effective debugging techniques for failed test cases. Regression testing is essential for ensuring that new code changes do not introduce new bugs or regressions. By following the steps outlined in this guide, you can contribute to maintaining a stable and reliable codebase.
The GUIX regression test is built on top of the CMake build system and organize its code in test\guix_test
folder. The foundational elements are structured as follows:
<test_name>.bin
.<test_name>.checksum
.install.sh
located in the scripts
directory.Navigate to the test\guix_test\cmake
directory.
To build and run all the tests, use the following commands.
./run.sh build all
./run.sh run all
./run.sh build <build_type>
./run.sh run <build_type>
The available build types are as follows:
Build Types | Description | Build Configuration Settings |
---|---|---|
default_build_coverage | Build with default configuration settings and generate coverage report | N/A |
disable_error_checking_build | Build with error checking disabled | GX_DISABLE_ERROR_CHECKING |
no_utf8_build_coverage | Build with UTF-8 support disabled and generate coverage report | GX_DISABLE_UTF8_SUPPORT and GX_DISABLE_ERROR_CHECKING |
no_utf8_no_checking_build | Build with UTF-8 support disabled and error checking disabled | GX_DISABLE_UTF8_SUPPORT and GX_DISABLE_ERROR_CHECKING |
ex_unicode_build | Build with extended Unicode support | GX_EXTENDED_UNICODE_SUPPORT |
ex_unicode_no_checking_build | Build with extended Unicode support and error checking disabled | GX_EXTENDED_UNICODE_SUPPORT and GX_DISABLE_ERROR_CHECKING |
mouse_support_build | Build with mouse support | GX_MOUSE_SUPPORT |
font_kerning_support_build | Build with font kerning support | GX_FONT_KERNING_SUPPORT |
dynamic_bidi_text_build | Build with dynamic bi-directional text support | GX_DYNAMIC_BIDI_TEXT_SUPPORT and GX_DYNAMIC_ARABIC_SHAPING_SUPPORT |
dynamic_bidi_text_no_checking_build | Build with dynamic bi-directional text support and error checking disabled | GX_DYNAMIC_BIDI_TEXT_SUPPORT, GX_DYNAMIC_ARABIC_SHAPING_SUPPORT and GX_DISABLE_ERROR_CHECKING |
_5_4_0_compatible_no_checking_build | Build with GUIX library version 5.4.0 compatibility and error checking disabled | GX_DISABLE_ERROR_CHECKING and GUIX_5_4_0_COMPATIBILITY |
synergy_font_support_build | Build with synergy font support | GX_SYNERGY_FONT_FORMAT_SUPPORT |
thai_glyph_shaping_support_build | Build with Thai glyph shaping support | GX_THAI_GLYPH_SHAPING_SUPPORT |
palette_mode_aa_text_colors_16_build | Build with palette mode with 16 colors for text drawing support | GX_PALETTE_MODE_AA_TEXT_COLORS=16 |
disable_deprecated_string_api_build | Build with deprecated string API disabled | GX_DISABLE_DEPRECATED_STRING_API |
partial_canvas_support_build | Build with partial canvas support | GX_ENABLE_CANVAS_PARTIAL_FRAME_BUFFER |
partial_canvas_support_vertical_refresh_build | Build with partial canvas support and vertical refresh | GX_ENABLE_CANVAS_PARTIAL_FRAME_BUFFER and GX_CANVAS_REFRESH_DIRECTION_VERTICAL |
partial_canvas_support_horizontal_refresh_build | Build with partial canvas support and horizontal refresh | GX_ENABLE_CANVAS_PARTIAL_FRAME_BUFFER and GX_CANVAS_REFRESH_DIRECTION_HORIZONTAL |
The test reports for each build type will be generated in the test\guix_test\cmake\build\<build_type>
directory.
The coverage report for default_build_covearge
and no_utf8_build_coverage
will be generated in the test\guix_test\cmake\coverage_report
directory. For other build types, no coverage report is generated.
Follow these steps to execute an individual test case:
Build the test using the instructions provided in the previous section.
Navigate to the test\guix_test\cmake\build\<build_type>\regression
directory, where the test executables are generated.
Run the test without output, where the test name is ended with no_output
.
./<test_name>
./<test_name> -checksum -gpath ../../../../golden_files/
test\guix_test\cmake\build\<build_type>\regression
directory, where the test executables are generated. Start cgdb using the following command.cgdb <test_name>
-r
to run test without comparison.set args -r
Navigate to the test\guix_test\cmake\build\<build_type>\regression\output_files
directory, where the failed output binary file is generated. The generated binary file is named <test_name>_failures.bin
.
Use gx_show_canvas.exe located in test\guix_test\regression_test
to display the content in the failed output binary file. Compare it with the corresponding golden file located in the test\guix_test\golden_files
directory. For the usage of gx_show_canvas.exe, please refer to gx_show_canvas.md.
Follow these steps to add a new test:
test\example_internal
directory.demo_guix_<example_name>.c
.test\guix_test\regression_test\tests
directory.validation_guix
.#include <stdio.h>
#include "tx_api.h"
#include "gx_api.h"
#include "gx_validation_utility.h"
TEST_PARAM test_parameter = {
"", /* Test name */
0, 0, 0, 0 /* Define the coordinates of the capture area.*/
};
Definition of the TEST_PARAM structure:
typedef struct TEST_PARAM_S
{
char *test_name; /* Must be set */
/* The following parameters defines the screen area to capture.
If 0, capture the whole screen. */
int x_start;
int y_start;
int x_end;
int y_end;
} TEST_PARAM;
int main(int argc, char ** argv)
{
/* Start ThreadX system */
tx_kernel_enter();
return(0);
}
static VOID control_thread_entry(ULONG);
VOID tx_application_define(void *first_unused_memory)
{
gx_validation_application_define(first_unused_memory);
/* Termiante the test if it runs for more than 100 ticks */
/* This function is not implemented yet. */
gx_validation_watchdog_create(100);
/* Create a dedicated thread to perform various operations
on the line drawing example. These operations simulate
user input. */
gx_validation_control_thread_create(control_thread_entry);
}
#ifdef WIN32
#undef WIN32
#endif
#include "gx_validation_wrapper.h"
#include "demo_guix_<example_name>.c"
The test example source code also contains a main function, The header file gx_validation_wrapper.h
is used to replace the main function in the test example source code.
static VOID control_thread_entry(ULONG input)
{
int failed_tests = 0;
UINT status;
GX_PROMPT *prompt = &button_screen.button_screen_title_1;
GX_CONST GX_CHAR *text;
gx_widget_hide(&button_screen);
status = gx_prompt_text_get(prompt, &text);
EXPECT_EQ(GX_INVALID_CANVAS, status);
if(failed_tests == 0)
{
gx_validation_print_test_result(TEST_SUCCESS);
exit(0);
}
else
{
gx_validation_print_test_result(TEST_FAIL);
exit(1);
}
}
static VOID control_thread_entry(ULONG input)
{
int frame_id = 1;
GX_EVENT my_event;
memset(&my_event, 0, sizeof(GX_EVENT));
my_event.gx_event_display_handle = 1;
gx_validation_set_frame_id(frame_id++);
gx_validation_set_frame_comment("Initialize the screen.");
gx_validation_screen_refresh();
/* Simulate a pen down event. */
my_event.gx_event_type = GX_EVENT_PEN_DOWN;
my_event.gx_event_payload.gx_event_pointdata.gx_point_x = 207;
my_event.gx_event_payload.gx_event_pointdata.gx_point_y = 376;
gx_system_event_send(&my_event);
/* Simulate a pen up event. */
my_event.gx_event_type = GX_EVENT_PEN_UP;
gx_system_event_send(&my_event);
/* Force a screen refresh to capture the canvas data or compare the checksum. */
gx_validation_set_frame_id(frame_id++);
gx_validation_set_frame_comment("Scroll the vertical list.");
gx_validation_screen_refresh();
/* Signal the end of the test case. Verify the output. */
gx_validation_end();
exit(0);
}
test\guix_test\cmake\regression\CMakeLists.txt
file.Types of Demo Lists | Description | Build Configuration Settings |
---|---|---|
NO_UTF8_DEMOS | Demos that do not support UTF-8 | GX_DISABLE_UT8_SUPPORT |
EXTENDED_UNICODE_DEMOS | Demos that support extended Unicode | GX_EXTENDED_UNICODE_SUPPORT |
OTHER_DEMOS | Demos with default configuration settings | N/A |
MOUSE_SUPPORT_DEMOS | Demos support mouse input | GX_MOUSE_SUPPORT |
FONT_KERNING_SUPPORT_DEMOS | Demos support font kerning | GX_FONT_KERNING_SUPPORT |
DYNAMIC_BIDI_TEXT_DEMOS | Demos support dynamic bi-directional text | GX_DYNAMIC_BIDI_TEXT_SUPPORT and GX_DYNAMIC_ARABIC_SHAPING_SUPPORT |
_5_4_0_COMPATIBLE_DEMOS | Demos that compatible with GUIX library version 5.4.0 | GUIX_5_4_0_COMPATIBILITY |
SYNERGY_FONT_SUPPORT_DEMOS | Demos that support synergy font | GX_SYNERGY_FONT_FORMAT_SUPPORT |
THAI_GLYPH_SHAPING_SUPPORT_DEMOS | Demos that support Thai glyph shaping | GX_THAI_GLYPH_SHAPING_SUPPORT |
PALETTE_MODE_AA_TEXT_COLORS_16_DEMOS | Demos that support palette mode with 16 colors for text drawing | GX_PALETTE_MODE_AA_TEXT_COLORS=16 |
PARTIAL_CANVAS_SUPPORT_DEMOS | Demos that support partial canvas | GX_ENABLE_CANVAS_PARTIAL_FRAME_BUFFER |
set(<example_name>_FILE_LIST
demo_guix_<example_name>.c
...)
set(<example_name>_REG_TESTS
<test_name>
...)
Build GUIX regression test with the appropriate build type based on the demo build configuration settings.
Generate golden files for the test case. If the test has no output, this step can be skipped.
Navigate to the test\guix_test\cmake\build\<build_type>\regression
directory, where the test executables are generated.
Generate output files for the test case with the following command.
./<test_name> -r -generate
After the command is executed, the output binary file <test_name>.bin
and checksum file <test_name>.checksum
will be generated in the test\guix_test\cmake\build\<build_type>\regression\output_files
directory.
Verify the correctness of the test by checking the content of the output binary file <test_name>.bin
with the gx_show_canvas.exe tool located in test\guix_test\regression_test
.
Compress the output binary file <test_name>.bin
into a 7z file with the following command.
7z a <test_name>.7z <test_name>.bin
<test_name>.7z
and <test_name>.checksum
to the test\guix_test\golden_files
directory.Run the GUIX regression test to see if the test case passes.
Now the test case is ready to be submitted to the GUIX repository.
If the available build types lack the configuration settings required for your test, you can add a new build type by following these steps:
test\guix_test\cmake\CMakeLists.txt
file.set(disable_error_checking_build -DGX_DISABLE_ERROR_CHECKING)
BUILD_CONFIGURATIONS
list.set(BUILD_CONFIGURATIONS
...
<new_build_type>
)
test\guix_test\cmake\regression\CMakeLists.txt
file.set (<demo_type_name> <example_name>)
set(EXAMPLE_INTERNAL_DIR ${ROOT_DIR}/example_internal)
foreach(
demo
...
${<demo_type_name>};
...
set(${demo}_SOURCE_DIRECTORY ${EXAMPLE_INTERNAL_DIR}/${demo})
endforeach()
demos
variable according to the build type. This variable will later be used to add test cases for the build type:...
elseif("-D<new_build_configuration>" IN_LIST ${CMAKE_BUILD_TYPE})
set(demos ${<demo_type_name>})
...
validation_*.c
and related source files, excluding demo_*
for the test cases of the new demo type:# Set regression test program's SOURCE as validation_*.c and related source
# files excluding demo_*
foreach(
demo
...
${<demo_type_name>};
...
endforeach()
The demo tests are located in the test\guix_studio_test\test_demo
directory.
Target Directories: examples
, tutorials
and test\example_internal
.
test\guix_studio_test\test_demo
directory.gxp
projects under the target directories, run the following command.test_main.py -b -t
-b
option is used to build the latest GUIX Studio executable.-t
option is used to verify the output files for the gxp
projects under the target directories.test_main.py --compile_project
gxp
projects under the target directories, run the following command.test_main.py -b -g
gxp
projects under the target directories, run the following command.test_main.py --update_gxp_project
gxp
projects under the target directories, run the following command.test_main.py -v <VERSION>
replace <VERSION>
with the actual GUIX library version. such as 6.2.0
.
After test execution, a test log file named output_files_test_log.txt
will be generated in the current directory. If a test case failed, the log file provides detailed information about the failure.
If you have added a new gxp
project under the target directories, this project will be automatically added to the test system. However, if your project involves the generation of binary files or other output files requiring verification, it is necessary to develop project-specific resource output logic. For guidance, you can consult the implementation of functions such as test_utils::test_one_project()
and test_utils.generate()
.
The test view tests are located in the test\guix_studio_test\test_view
directory.
Figure 1: GUIX Studio Test View Architecture
GUIX Studio provides a test message handler for each function component, enabling interaction with the GUIX Studio Test View, a Python based test application that communicates with GUIX Studio by transmitting messages through these handlers. The test_utils.py
module facilitates the sending of messages to individual function components within GUIX Studio. Utilizing these functions allows you to simulate user actions for the purpose of testing GUIX Studio. For example, you can use test_utils::open_project()
to open a project in GUIX Studio.
GUIX Studio Test View verifies the correctness of the test through two aspects:
Comparing the checksum of the canvas data with the corresponding value stored in the golden files. The test_utils.py
module includes the test_utils::compare_result()
function, which facilitates this comparison process. In test mode, it checks the checksum of the canvas data against the correct value in the golden files. In generation mode, the function generates checksum values and stores them in the specified golden file.
Comparing the output files of the testing gxp
project with the corresponding files stored in the golden_files
directory. the test_utils.py
module includes the test_utils::cmp_output_files()
function, which facilitates this comparison process.
test\guix_studio_test\test_view
directory.test_main.py -b
test_main.py -b <test_name>
To explore the available test cases and obtain more information, use the following command to display the help message:
test_main.py -h
After test execution, a test log file named studio_view_test_log.txt
will be generated in the current directory. If a test case failed, the log file provides detailed information about the failure. If the test fails due to canvas data mismatch, a test_failure
folder is generated in the current directory, which contains the screenshot of the failed test case.
import os
import sys
import time
import test_utils
import test_constants
def get_test_header():
notes = "* <Test Name> *\n"
notes += "* *\n"
...
return notes
def <test_name>(generate, screenshot):
test_utils.output_test_header(get_test_header())
test_utils.setup(generate, screenshot, <golden_file_name>)
# Test code goes here.
test_utils.write_end(<test_name>)
test_main.py
.from <test_file_name> import <test_name>
parser.add_argument('--<test_name>', action='store_true', dest='<test_name>' help='Run <test_name> test')
if (... and
args.<test_name> is False):
...
test_utils.<test_name> = True
...
if test_utils.<test_name>:
<test_name>(args.generate, args.screenshot)
test_main.py -b --<test_name> -g
test\guix_studio_test\golden_files
directory.test_main.py -b --<test_name>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。