Commit 7b743fa7 authored by Stephanie Gawroriski's avatar Stephanie Gawroriski
Browse files

Add auto-generated listing of tests so the test names do not need to be put in manually.

parent 332a2204
Pipeline #40451 passed with stages
in 2 minutes
......@@ -16,6 +16,8 @@
#ifndef BUILDVM_ENTRY_H
#define BUILDVM_ENTRY_H
#include "sjmerc.h"
/* Anti-C++. */
#ifdef __cplusplus
#ifndef SJME_CXX_IS_EXTERNED
......@@ -28,6 +30,16 @@ extern "C"
/*--------------------------------------------------------------------------*/
/**
* Main BVM entry point.
*
* @param argc Argument count.
* @param argv Arguments.
* @return The exit status of the process.
* @since 2021/07/24
*/
sjme_jboolean bvm_main(int argc, char** argv);
/*--------------------------------------------------------------------------*/
/* Anti-C++. */
......
......@@ -16,6 +16,139 @@
#ifndef BUILDVM_SJMERC_H
#define BUILDVM_SJMERC_H
/** Is this a 64-bit system? */
#if !defined(SJME_BITS)
#if defined(_LP64) || defined(__LP64__) || defined(__x86_64__) || \
defined(_M_X64) || defined(_M_AMD64) || defined(__aarch64__) || \
defined(__ia64__) || defined(__ia64) || defined(_M_IA64) || \
defined(__itanium__) || defined(__powerpc64__) || \
defined(__ppc64__) || defined(_ARCH_PPC64) || defined(_ARCH_PPC64)
#define SJME_BITS 64
#else
#define SJME_BITS 32
#endif
#endif
/** Possibly detect endianess. */
#if !defined(SJME_BIG_ENDIAN) && !defined(SJME_LITTLE_ENDIAN)
/** Defined by the system? */
#if !defined(SJME_BIG_ENDIAN)
#if defined(MSB_FIRST) || \
(defined(WORDS_BIGENDIAN) && WORDS_BIGENDIAN != 0)
#define SJME_BIG_ENDIAN
#endif
#endif
/** Just set little endian if no endianess was defined */
#if !defined(SJME_BIG_ENDIAN) && !defined(SJME_LITTLE_ENDIAN)
#define SJME_LITTLE_ENDIAN
#endif
/** If both are defined, just set big endian. */
#if defined(SJME_BIG_ENDIAN) && defined(SJME_LITTLE_ENDIAN)
#undef SJME_LITTLE_ENDIAN
#endif
#endif
/** Linux. */
#if defined(__linux__) || defined(__gnu_linux__)
#define SJME_IS_LINUX 1
#endif
/** DOS? */
#if defined(MSDOS) || defined(_MSDOS) || defined(__MSDOS__) || defined(__DOS__)
#define SJME_IS_DOS 1
#include <malloc.h>
#endif
/** C99 includes. */
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
(defined(__WATCOMC__) && __WATCOMC__ >= 1270) || \
(defined(_MSC_VER) && _MSC_VER >= 1600) || \
(defined(__GNUC__) && __GNUC__ >= 4) || \
(defined(PSP) || defined(PS2))
#include <stdint.h>
/** Old Microsoft. */
#elif defined(_MSC_VER) && _MSC_VER < 1600
typedef signed __int8 int8_t;
typedef signed __int16 int16_t;
typedef signed __int32 int32_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
#define INT8_C(x) x
#define INT16_C(x) x
#define INT32_C(x) x
#define UINT8_C(x) x##U
#define UINT16_C(x) x##U
#define UINT32_C(x) x##U
/** Palm OS. */
#elif defined(__palmos__)
#include <PalmTypes.h>
typedef Int8 int8_t;
typedef Int16 int16_t;
typedef Int32 int32_t;
typedef UInt8 uint8_t;
typedef UInt16 uint16_t;
typedef UInt32 uint32_t;
typedef int32_t intptr_t;
typedef uint32_t uintptr_t;
#define INT8_C(x) x
#define INT16_C(x) x
#define INT32_C(x) x##L
#define UINT8_C(x) x##U
#define UINT16_C(x) x##U
#define UINT32_C(x) x##UL
#define SIZE_MAX UINT32_C(0xFFFFFFFF)
/** Guessed otherwise. */
#else
#if defined(SCHAR_MAX) && SCHAR_MAX == 127
typedef signed char int8_t;
#define INT8_C(x) x
#endif
#if defined(INT_MAX) && INT_MAX == 32767
typedef signed int int16_t;
typedef unsigned int uint16_t;
#define INT16_C(x) x
#define UINT16_C(x) x##U
#elif defined(SHORT_MAX) && SHORT_MAX == 32767
typedef signed short int16_t;
typedef unsigned short uint16_t;
#define INT16_C(x) x
#define UINT16_C(x) x##U
#endif
#if defined(INT_MAX) && INT_MAX > 32767
typedef signed int int32_t;
typedef unsigned int uint32_t;
#define INT32_C(x) x
#elif defined(LONG_MAX) && LONG_MAX > 32767
typedef signed long int32_t;
typedef unsigned long uint32_t;
#define INT32_C(x) x##L
#define UINT32_C(x) x##UL
#endif
#endif
/* Anti-C++. */
#ifdef __cplusplus
#ifndef SJME_CXX_IS_EXTERNED
......@@ -28,6 +161,51 @@ extern "C"
/*--------------------------------------------------------------------------*/
/** {@code byte} type. */
typedef int8_t sjme_jbyte;
/** {@code short} type. */
typedef int16_t sjme_jshort;
/** {@code char} type. */
typedef uint16_t sjme_jchar;
/** {@code int} type. */
typedef int32_t sjme_jint;
/** Unsigned {@code int} type. */
typedef uint32_t sjme_juint;
/** Constant value macros. */
#define SJME_JBYTE_C(x) INT8_C(x)
#define SJME_JSHORT_C(x) INT16_C(x)
#define SJME_JCHAR_C(x) UINT16_C(x)
#define SJME_JINT_C(x) INT32_C(x)
#define SJME_JUINT_C(x) UINT32_C(x)
/** Maximum values. */
#define SJME_JINT_MAX_VALUE INT32_C(0x7FFFFFFF)
/** Unsigned short mask. */
#define SJME_JINT_USHORT_MASK INT32_C(0xFFFF)
/** Boolean type. */
typedef enum sjme_jboolean
{
sjme_false = 0,
sjme_true = 1,
} sjme_jboolean;
/** This represents an error. */
typedef struct sjme_error
{
/** Error code. */
sjme_jint code;
/** The value of it. */
sjme_jint value;
} sjme_error;
/*--------------------------------------------------------------------------*/
/* Anti-C++. */
......
......@@ -7,3 +7,9 @@
// See license.mkd for licensing and copyright information.
// -------------------------------------------------------------------------*/
#include "entry.h"
sjme_jboolean bvm_main(int argc, char** argv)
{
return sjme_false;
}
......@@ -7,3 +7,20 @@
// See license.mkd for licensing and copyright information.
// -------------------------------------------------------------------------*/
#include <stdlib.h>
#include "entry.h"
/**
* Main UNIX entry point.
*
* @param argc Argument count.
* @param argv Arguments.
* @return The exit status of the process.
* @since 2021/07/24
*/
int main(int argc, char** argv)
{
if (bvm_main(argc, argv) == sjme_true)
return EXIT_SUCCESS;
return EXIT_FAILURE;
}
\ No newline at end of file
......@@ -7,19 +7,21 @@
// See license.mkd for licensing and copyright information.
// -------------------------------------------------------------------------*/
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include "entry.h"
/**
* Main Windows entry point.
*
* @param argc Argument count.
* @param argv Arguments.
* @return The exit status of the process.
* @since 2021/07/24
*/
int main(int argc, char** argv)
{
int i;
fprintf(stderr, "Args %d\r\n", argc);
for (i = 0; i < argc; i++)
fprintf(stderr, "Arg[%d]: %s\r\n", i, argv[i]);
fflush(stderr);
if (bvm_main(argc, argv) == sjme_true)
return EXIT_SUCCESS;
return EXIT_FAILURE;
}
......@@ -15,7 +15,10 @@ add_executable(BuildVMTests
# Additional includes
target_include_directories(BuildVMTests PUBLIC
"${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/include")
"${PROJECT_BINARY_DIR}"
"${PROJECT_SOURCE_DIR}/include"
"${CMAKE_CURRENT_BINARY_DIR}" # Generated sources!
)
# Link in core SquirrelJME, make it static so there are no dependencies
target_link_libraries(BuildVMTests
......@@ -25,6 +28,10 @@ target_link_libraries(BuildVMTests
add_compile_definitions(SQUIRRELJME_VERSION="${SQUIRRELJME_VERSION}")
add_compile_definitions(SQUIRRELJME_VERSION_ID="${SQUIRRELJME_VERSION_ID}")
# Auto-generate tests
configure_file(blank.h.in prototype.h)
configure_file(blank.h.in listing.h)
# Used to wrap for QEMU and otherwise
if(DEFINED BUILDVM_TEST_WRAPPER)
message("Wrapping tests in ${BUILDVM_TEST_WRAPPER}...")
......@@ -48,13 +55,20 @@ foreach(BUILDVM_TEST_SOURCE ${BUILDVM_TEST_SOURCES})
message("Adding test ${BUILDVM_TEST_SOURCE}...")
if(DEFINED BUILDVM_TEST_WRAPPER)
add_test(NAME ${BUILDVM_TEST_SOURCE}
COMMAND "${BUILDVM_TEST_WRAPPER}" "$<TARGET_FILE:SquirrelJMETests>" ${BUILDVM_TEST_SOURCE})
COMMAND "${BUILDVM_TEST_WRAPPER}" "$<TARGET_FILE:BuildVMTests>" ${BUILDVM_TEST_SOURCE})
else()
add_test(NAME ${BUILDVM_TEST_SOURCE}
COMMAND SquirrelJMETests ${BUILDVM_TEST_SOURCE})
COMMAND BuildVMTests ${BUILDVM_TEST_SOURCE})
endif()
# Code for skipped tests
set_property(TEST ${BUILDVM_TEST_SOURCE} PROPERTY SKIP_RETURN_CODE 42)
set_tests_properties(${BUILDVM_TEST_SOURCE} PROPERTIES SKIP_RETURN_CODE 42)
# Add test to the generated sources, so that we need not manually store
# every test we know about
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/prototype.h"
"SJME_TEST_PROTOTYPE(${BUILDVM_TEST_SOURCE});\n")
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/listing.h"
"SJME_TEST(${BUILDVM_TEST_SOURCE}),\n")
endforeach()
/* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// -------------------------------------------------------------------------*/
......@@ -66,7 +66,7 @@ typedef struct sjme_singleTest
/** Test table. */
static const sjme_singleTest sjme_singleTests[] =
{
/*SJME_TEST(testAtomic),*/
#include "listing.h"
/* End of tests. */
{NULL, NULL}
......@@ -90,7 +90,7 @@ int main(int argc, char** argv)
sjme_jint errorBufLen;
/* General test report. */
fprintf(stderr, "Testing SquirrelJME %s\n",
fprintf(stderr, "Testing SquirrelJME BootVM %s\n",
SQUIRRELJME_VERSION" ("SQUIRRELJME_VERSION_ID")");
fflush(stderr);
......@@ -159,18 +159,15 @@ int main(int argc, char** argv)
fflush(stderr);
/* Note error code, if any. */
if (sjme_hasError(&shim->error))
if (shim->error.code != 0)
{
/* Reset error buffer. */
memset(errorBuf, 0, sizeof(errorBuf));
errorBufLen = ERROR_BUF_LEN;
/* Describe it. */
sjme_describeJvmError(&shim->error, errorBuf, &errorBufLen);
/* Print it. */
fprintf(stderr, "Test %s error: %s\n",
test->name, errorBuf);
fprintf(stderr, "Test %s error: %d %d\n",
test->name, shim->error.code, shim->error.value);
fflush(stderr);
}
......
/* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// -------------------------------------------------------------------------*/
#include "tests.h"
SJME_TEST_PROTOTYPE(testSkip)
{
return SKIP_TEST();
}
\ No newline at end of file
/* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// -------------------------------------------------------------------------*/
#include "tests.h"
SJME_TEST_PROTOTYPE(testSuccess)
{
return PASS_TEST();
}
......@@ -21,6 +21,8 @@
*/
typedef struct sjme_testShim
{
/** The current error state. */
sjme_error error;
} sjme_testShim;
/**
......@@ -40,6 +42,6 @@ typedef struct sjme_testShim
#define SKIP_TEST() SJME_JINT_C(-65535)
/* Available tests. */
/*SJME_TEST_PROTOTYPE(testAtomic);*/
#include "prototype.h"
#endif /* SQUIRRELJME_TESTS_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment