Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1716ec0
Request -> Peek
jc-luna Apr 21, 2026
e8df23f
Glob all srcs and headers
jc-luna Apr 21, 2026
a377c82
Remote stoppage of the daemon
jc-luna Apr 21, 2026
7875d5b
Reorganize sources: ipc -> sock
jc-luna Apr 21, 2026
bdd759b
maybe ifdefing in a struct is evil
jc-luna Apr 22, 2026
a60b1bd
Enforce header order
jc-luna Apr 22, 2026
1e18991
Small trivial sockname unit test
jc-luna Apr 22, 2026
6e85319
CTest on CI
jc-luna Apr 22, 2026
52bdc60
Emit warnings this way
jc-luna Apr 22, 2026
7948f2e
Test the proc spawner
jc-luna Apr 22, 2026
28db905
Simple socket full run test
jc-luna Apr 22, 2026
ca01f97
Windows define a socklen_t
jc-luna Apr 22, 2026
80773e8
Race condition guard in test
jc-luna Apr 22, 2026
b643d78
Don't epicly fail because of a leading space
jc-luna Apr 22, 2026
d00bf57
Don't allow accidental writes to parent STDIN
jc-luna Apr 22, 2026
db5732e
Windows Semicolon
jc-luna Apr 22, 2026
322ec9a
Add ws2tcpip.h for Windows for socklen_t typedef
jc-luna Apr 22, 2026
dd45915
Zero-init proc info structs, improve test err msgs
jc-luna Apr 22, 2026
04fc006
Improved error printers
jc-luna Apr 22, 2026
6449d76
Move new perror out of ifdef
jc-luna Apr 22, 2026
9650340
Just use ANSI chars on windows perror
jc-luna Apr 22, 2026
d294729
Opening and closing a sock rq
jc-luna Apr 22, 2026
384dc05
Use the proper fd mate!
jc-luna Apr 23, 2026
c34d713
Remove windows socklen ifdefs
jc-luna Apr 23, 2026
9f5b358
Simple daemon interrupt test
jc-luna Apr 23, 2026
de626d8
Wrap in a string so it doesn't fail
jc-luna Apr 24, 2026
29b86a6
Fix newproc function
jc-luna Apr 25, 2026
28962da
More explict non-constness
jc-luna Apr 25, 2026
43fea3a
Merge pull request #29 from team-gets/ctest-unit-tests
jc-luna Apr 25, 2026
af4ff36
Silence another strstr discarded qual warn
jc-luna Apr 25, 2026
89aabf2
Don't output an error when canceling in some cases
jc-luna Apr 25, 2026
ae68c57
Consistent capitalization in printed msgs
jc-luna Apr 25, 2026
70a372b
INVALID_SOCKET define to sock.h
jc-luna Apr 25, 2026
a8111d7
Linux piper impl
jc-luna Apr 25, 2026
c976cf6
Explict set last arg passed to execv to NULL
jc-luna Apr 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions .github/workflows/build-cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@ on:
branches: ["main"]
paths:
- ".github/workflows/build-cmake.yml"
- "ipc/**/*.c"
- "ipc/**/*.h"
- "test/*.c"
- "**/*.c"
- "**/*.h"
- "**/CMakeLists.txt"
- "cmake/*.cmake"
push:
branches: ["main"]
paths:
- ".github/workflows/build-cmake.yml"
- "ipc/**/*.c"
- "ipc/**/*.h"
- "test/*.c"
- "**/*.c"
- "**/*.h"
- "**/CMakeLists.txt"
- "cmake/*.cmake"

Expand All @@ -38,6 +36,9 @@ jobs:
- name: Build
run: |
cmake --build build
- name: Test
run: |
ctest --verbose --output-on-failure --test-dir ${{ github.workspace }}/build/test

windows-build-cmake:
name: Windows
Expand All @@ -57,3 +58,6 @@ jobs:
- name: Build
run: |
cmake --build build
- name: Test
run: |
ctest --verbose --output-on-failure --test-dir ${{ github.workspace }}/build/test
23 changes: 16 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
project(libtestrig
LANGUAGES C)

include(CTest)
include(target_copy_dll)
include(target_output_to_bin)
include(target_compile_warn_all)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib")
Expand All @@ -15,6 +17,8 @@ set(BIN_DIR "${CMAKE_SOURCE_DIR}/bin")

set(IPC_SOURCES
"${IPC_DIR}/ipc.c"
"${IPC_DIR}/pipe.c"
"${IPC_DIR}/sock.c"
"${IPC_DIR}/message.c"
"${IPC_DIR}/os.c")

Expand All @@ -27,13 +31,6 @@ set(EPOS_SOURCES

set(LIBTESTRIG_SOURCES ${IPC_SOURCES} ${EPOS_SOURCES})

if (MSVC)
add_compile_options("/W4")
else()
add_compile_options("-Wall")
endif()


if (WIN32)
add_library(EposCmd SHARED IMPORTED)
set_target_properties(EposCmd PROPERTIES
Expand All @@ -50,14 +47,26 @@ else()
set(EposCmd-FOUND TRUE)
endif()

if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
message("-- Creating coverage reports in Debug mode.")
add_compile_options(-coverage)
add_link_options(-coverage)
endif()

add_library(libtestrig SHARED ${LIBTESTRIG_SOURCES})
target_compile_definitions(libtestrig PRIVATE COMPILING_TESTRIG_DLL)
target_include_directories(libtestrig PUBLIC ${LIB_DIR})
target_link_libraries(libtestrig PUBLIC EposCmd)
target_compile_warn_all(libtestrig)
target_output_to_bin(libtestrig)
set_target_properties(libtestrig
PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON)

if (WIN32)
target_link_libraries(libtestrig PUBLIC Ws2_32 Kernel32)
endif()

add_library(vscl::testrig::lib ALIAS libtestrig)

add_subdirectory("${CMAKE_SOURCE_DIR}/src")
add_subdirectory("${CMAKE_SOURCE_DIR}/test")
1 change: 1 addition & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"CMAKE_COLOR_DIAGNOSTICS": "ON"
}
},

{
"name": "windows-only",
"hidden": true,
Expand Down
7 changes: 7 additions & 0 deletions cmake/target_compile_warn_all.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function(target_compile_warn_all IN_TARGET_NAME)
if (MSVC)
target_compile_options(${IN_TARGET_NAME} PRIVATE "/W4")
else()
target_compile_options(${IN_TARGET_NAME} PRIVATE "-Wall")
endif()
endfunction(target_compile_warn_all IN_TARGET_NAME)
14 changes: 7 additions & 7 deletions lib/epos2/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "identify.h"

static void vscl_failed_open_device(uint32_t error_code) {
vscl_print_error(error_code);
vscl_rig_perror(error_code);
printf("Failed to open device with with following characteristics:\n");
}

Expand Down Expand Up @@ -53,7 +53,7 @@ uint32_t vscl_initialize_devices(struct controller controllers_out[], void* hand
error_code = vscl_clean_enable_device(&controllers_out[0], handles_out[0]);
if (error_code != 0) {
printf("While attempting to open gateway:\n\t");
vscl_print_error(error_code);
vscl_rig_perror(error_code);

return error_code;
}
Expand All @@ -77,7 +77,7 @@ uint32_t vscl_initialize_devices(struct controller controllers_out[], void* hand
error_code = vscl_clean_enable_device(&controllers_out[i], handles_out[i]);
if (error_code != 0) {
printf("While attempting to open gateway:\n\t");
vscl_print_error(error_code);
vscl_rig_perror(error_code);
return error_code;
}
}
Expand All @@ -100,7 +100,7 @@ uint32_t vscl_clean_enable_device(struct controller* controller, void* device_ha
ret = VCS_ClearFault(device_handle, controller->node_id, &error_code);
if (ret == 0) {
printf("While clearing fault from %s at %s:\n\t", controller->name, controller->port);
vscl_print_error(error_code);
vscl_rig_perror(error_code);
return error_code;
}

Expand All @@ -125,7 +125,7 @@ uint32_t vscl_close_device(struct controller* controller, void* device_handle) {
if (ret == 0) {
printf("While attempting to close device %s at node %ihh\n\t",
controller->name, controller->node_id);
vscl_print_error(error_code);
vscl_rig_perror(error_code);
return error_code;
}

Expand Down Expand Up @@ -156,7 +156,7 @@ uint32_t vscl_close_devices(struct controller controllers[], void* device_handle
if (ret == 0) {
printf("While closing subdevice %s at node %ihh:\n\t",
controllers[i].name, controllers[i].node_id);
vscl_print_error(error_code);
vscl_rig_perror(error_code);

return error_code;
}
Expand All @@ -169,7 +169,7 @@ uint32_t vscl_close_devices(struct controller controllers[], void* device_handle
if (ret == 0) {
printf("While closing gateway device %s at node %ihh:\n\t",
controllers[0].name, controllers[0].node_id);
vscl_print_error(error_code);
vscl_rig_perror(error_code);
return error_code;
}

Expand Down
8 changes: 4 additions & 4 deletions lib/epos2/epos2.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ int vscl_decode_error(const uint32_t error_code, char* error_msg, vscl_byte_t ma
return ret;
}

int vscl_print_error(const uint32_t error_code) {
int vscl_rig_perror(const uint32_t error_code) {
char msg[64] = { 0 };
int ret = vscl_decode_error(error_code, msg, 64);
printf("ERROR 0x%X: %s\n", error_code, msg);
Expand All @@ -24,7 +24,7 @@ uint32_t vscl_reset_device(void *device_handle, struct controller* controller_in
uint32_t error_code = 0;
int ret = VCS_ResetDevice(device_handle, controller_in->node_id, &error_code);
if (ret == 0) {
vscl_print_error(error_code);
vscl_rig_perror(error_code);
printf("Device failed to be reset: %s\n", controller_in->name);
}

Expand All @@ -47,7 +47,7 @@ uint32_t vscl_setup_can_gateway(struct controller controllers[3], void* handles[
error_code = vscl_initialize_devices(controllers, handles, 3);
if (error_code != 0) {
printf("When initializing multiple devices: ");
vscl_print_error(error_code);
vscl_rig_perror(error_code);
return error_code;
}

Expand All @@ -60,7 +60,7 @@ uint32_t vscl_cleanup_testrig(struct controller controllers[3], void* handles[3]
error_code = vscl_close_devices(controllers, handles, 3);
if (error_code != 0) {
printf("When cleaning up multiple devices: ");
vscl_print_error(error_code);
vscl_rig_perror(error_code);
return error_code;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/epos2/epos2.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ int TESTRIG_API vscl_decode_error(const uint32_t error_code, char* error_msg, vs
/*
* @brief Decode and print an error code's corresponding message.
*/
int TESTRIG_API vscl_print_error(const uint32_t error_code);
int TESTRIG_API vscl_rig_perror(const uint32_t error_code);

/*
* @brief Reset a device.
Expand Down
8 changes: 4 additions & 4 deletions lib/epos2/identify.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@

static void vscl_print_naming_error(vscl_byte_t error_code) {
printf("While identifying device names:\n\t");
vscl_print_error(error_code);
vscl_rig_perror(error_code);
}

static void vscl_print_protocol_ident_error(vscl_byte_t error_code, const char* name) {
printf("While identifying device protocol stacks for device %s:\n\t", name);
vscl_print_error(error_code);
vscl_rig_perror(error_code);
}

static void vscl_print_interface_ident_error(vscl_byte_t error_code, const char* name, const char* protocol) {
printf("While identifying device interface for device %s on protocol %s:\n\t", name, protocol);
vscl_print_error(error_code);
vscl_rig_perror(error_code);
}

static void vscl_print_port_ident_error(vscl_byte_t error_code, const char* name, const char* protocol, const char* iface) {
printf("While identifying device interface for device %s on protocol %s and interface %s:\n\t",
name, protocol, iface);
vscl_print_error(error_code);
vscl_rig_perror(error_code);
}

uint32_t vscl_ident_names(void) {
Expand Down
2 changes: 1 addition & 1 deletion lib/epos2/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ uint32_t vscl_abort(const struct controller* controller_in, void* device_handle)

int ret = VCS_SetQuickStopState(device_handle, controller_in->node_id, &error_code);
if (ret == 0) {
vscl_print_error(error_code);
vscl_rig_perror(error_code);
printf("DANGER: Failed to abort rig operations!\n");
}
else {
Expand Down
Loading