Add test for buffer transforms

* tests/Imakefile (OBJS3, SRCS3): New program.
(PROGRAMS): Add transform_test.
* tests/README: Document what these tests are.
* tests/damage_test.c (test_names): Fix coding style.
* tests/run_tests.sh (standard_tests): Add `standard_tests'.
* tests/svnignore.txt: Add transform_test.
* tests/test_harness.c (load_image_data): Fix stride validation
when height > width.
* tests/test_harness.h (FALLTHROUGH): New macro.
This commit is contained in:
hujianwei 2022-11-04 07:22:57 +00:00
parent 2875ae8df1
commit 6a0506a169
7 changed files with 20 additions and 5 deletions

View file

@ -25,7 +25,9 @@ ScannerTarget(12to11-test)
OBJS1 = $(COMMONOBJS) simple_test.o OBJS1 = $(COMMONOBJS) simple_test.o
SRCS2 = $(COMMONSRCS) damage_test.c SRCS2 = $(COMMONSRCS) damage_test.c
OBJS2 = $(COMMONOBJS) damage_test.o OBJS2 = $(COMMONOBJS) damage_test.o
PROGRAMS = simple_test damage_test SRCS3 = $(COMMONSRCS) transform_test.c
OBJS3 = $(COMMONSRCS) transform_test.o
PROGRAMS = simple_test damage_test transform_test
/* Make all objects depend on HEADER. */ /* Make all objects depend on HEADER. */
$(OBJS1): $(HEADER) $(OBJS1): $(HEADER)
@ -35,6 +37,7 @@ depend:: $(HEADER) $(SRCS1)
NormalProgramTarget(simple_test,$(OBJS1),NullParameter,$(LOCAL_LIBRARIES),NullParameter) NormalProgramTarget(simple_test,$(OBJS1),NullParameter,$(LOCAL_LIBRARIES),NullParameter)
NormalProgramTarget(damage_test,$(OBJS2),NullParameter,$(LOCAL_LIBRARIES),NullParameter) NormalProgramTarget(damage_test,$(OBJS2),NullParameter,$(LOCAL_LIBRARIES),NullParameter)
DependTarget3($(SRCS1),$(SRCS2),NullParameter) NormalProgramTarget(transform_test,$(OBJS3),NullParameter,$(LOCAL_LIBRARIES),NullParameter)
DependTarget3($(SRCS1),$(SRCS2),$(SRCS3))
all:: $(PROGRAMS) all:: $(PROGRAMS)

View file

@ -12,5 +12,10 @@ When tests are being run, the tester must be very careful to not
interfere with the test operation by moving or resizing the test interfere with the test operation by moving or resizing the test
window. A compositing manager should be running along with the test. window. A compositing manager should be running along with the test.
These tests are supposed to test the functionality of the protocol
translator by connecting to a running instance and validating the
results of various high-level requests. In modern parlance, they
would be ``integration tests''.
Most likely, you do not want to run these tests manually, as the Most likely, you do not want to run these tests manually, as the
`run_tests.sh' script does all the setup for you. `run_tests.sh' script does all the setup for you.

View file

@ -30,7 +30,7 @@ static const char *test_names[] =
{ {
"map_window", "map_window",
"basic_test_card_image", "basic_test_card_image",
"basic_damage" "basic_damage",
}; };
#define LAST_TEST BASIC_DAMAGE_KIND #define LAST_TEST BASIC_DAMAGE_KIND

View file

@ -18,7 +18,7 @@
# along with 12to11. If not, see <https://www.gnu.org/licenses/>. # along with 12to11. If not, see <https://www.gnu.org/licenses/>.
pushd "$(dirname $0)" pushd "$(dirname $0)"
declare -a standard_tests=( simple_test damage_test ) declare -a standard_tests=( simple_test damage_test transform_test )
make -C . "${standard_tests[@]}" make -C . "${standard_tests[@]}"

View file

@ -3,5 +3,6 @@
vgcore* vgcore*
simple_test simple_test
damage_test damage_test
transform_test
Makefile Makefile
Makefile.bak Makefile.bak

View file

@ -586,7 +586,7 @@ load_image_data (const char *filename, struct image_data_header *header)
bpp = bytes_per_pixel_for_format (header->format); bpp = bytes_per_pixel_for_format (header->format);
if (!bpp || header->stride < header->height * bpp) if (!bpp || header->stride < header->width * bpp)
goto error_1; goto error_1;
buffer = malloc (header->stride * header->height); buffer = malloc (header->stride * header->height);

View file

@ -91,3 +91,9 @@ extern void test_init (void);
extern void test_complete (void) __attribute__ ((noreturn)); extern void test_complete (void) __attribute__ ((noreturn));
#define ARRAYELTS(arr) (sizeof (arr) / sizeof (arr)[0]) #define ARRAYELTS(arr) (sizeof (arr) / sizeof (arr)[0])
#if __GNUC__ >= 7
#define FALLTHROUGH __attribute__ ((fallthrough))
#else
#define FALLTHROUGH ((void) 0)
#endif