Use cmocka to test CLI

reverse-scroll
nirenjan 2021-07-30 03:03:16 -07:00
parent abdf47d721
commit 51913094cb
11 changed files with 7050 additions and 737 deletions

View File

@ -12,14 +12,14 @@ x52cli_CFLAGS = -I $(top_srcdir)/libx52 $(WARN_CFLAGS)
x52cli_LDFLAGS = $(WARN_LDFLAGS) x52cli_LDFLAGS = $(WARN_LDFLAGS)
x52cli_LDADD = libx52.la x52cli_LDADD = libx52.la
# TODO: Automake doesn't recognize these tests as scripts, and looks for if HAVE_CMOCKA
# C sources. We need to replace these tests with a CMocka test suite TESTS += test-cli
CLI_TESTS = \ check_PROGRAMS += test-cli
cli/cli_test_leds \
cli/cli_test_brightness \
cli/cli_test_indicator \
cli/cli_test_mfd \
cli/cli_test_clock \
cli/cli_test_timezone
EXTRA_DIST += cli/common_infra.sh $(CLI_TESTS) test_cli_SOURCES = cli/x52_cli.c cli/test_x52_cli.c
test_cli_CFLAGS = -DX52_CLI_TESTING -I $(top_srcdir)/libx52
test_cli_LDFLAGS = @CMOCKA_LIBS@ $(WARN_LDFLAGS)
# Add a dependency on test_x52_cli_tests.c
cli/test_x52_cli.c: cli/test_x52_cli_tests.c
endif

View File

@ -1,35 +0,0 @@
#!/usr/bin/env bash
# MFD & LED brightness tests
#
# Copyright (C) 2012-2018 Nirenjan Krishnan (nirenjan@nirenjan.org)
#
# SPDX-License-Identifier: GPL-2.0-only WITH Classpath-exception-2.0
source $(dirname $0)/cli/common_infra.sh
TEST_SUITE_ID="libx52 MFD & LED brightness tests"
brightness_test()
{
local unit=$(echo $1 | tr a-z A-Z)
local bri=$(printf '0x%04x' $2)
local index="\$X52_${unit}_BRIGHTNESS_INDEX"
TEST_ID="Test setting $unit brightness to $bri"
expect_pattern $(eval echo $index) $bri
$X52CLI bri $unit $bri
verify_output
}
for unit in mfd led
do
for bri in $(seq 0 128)
do
brightness_test $unit $bri
done
done
verify_test_suite

View File

@ -1,210 +0,0 @@
#!/usr/bin/env bash
# Clock tests
#
# Copyright (C) 2012-2018 Nirenjan Krishnan (nirenjan@nirenjan.org)
#
# SPDX-License-Identifier: GPL-2.0-only WITH Classpath-exception-2.0
source $(dirname $0)/cli/common_infra.sh
TEST_SUITE_ID="libx52 clock tests"
clock_test_utc()
{
local timezone=$1
local time_format=$2
local date_format=$3
TEST_ID="Test setting clock to $timezone time, $time_format, $date_format"
local dd=$(date +%_d)
local mm=$(date +%_m)
local yy=$(date +%_y)
local hr=$(date +%_H)
local mn=$(date +%_M)
local clock_value=$(($hr * 256 + $mn))
if [[ $time_format == 24hr ]]
then
clock_value=$(($clock_value + 32768))
fi
case $date_format in
ddmmyy)
date_value=$(($mm * 256 + $dd))
year_value=$yy
;;
mmddyy)
date_value=$(($dd * 256 + $mm))
year_value=$yy
;;
yymmdd)
date_value=$(($mm * 256 + $yy))
year_value=$dd
;;
*)
;;
esac
expect_pattern \
$X52_CLOCK_DATE_INDEX $(printf '%04x' $date_value) \
$X52_CLOCK_YEAR_INDEX $(printf '%04x' $year_value) \
$X52_CLOCK_1_INDEX $(printf '%04x' $clock_value) \
$X52CLI clock $timezone $time_format $date_format
verify_output
}
offset_test()
{
local clock_id=$1
local offset=$2
local time_format=$3
TEST_ID="Test setting clock $clock_id offset to $offset, $time_format"
local index="\$X52_CLOCK_${clock_id}_INDEX"
local value=0
# Handle negative case
if [[ $offset -lt 0 ]]
then
value=$((-$offset))
value=$(($value & 0x3ff))
value=$(($value | 1024))
else
value=$offset
fi
if [[ $time_format == 24hr ]]
then
value=$(($value + 32768))
fi
expect_pattern $(eval echo $index) $(printf '%04x' $value)
$X52CLI offset $clock_id $offset $time_format
verify_output
}
raw_time_test()
{
local hh=$1
local mm=$2
local time_format=$3
TEST_ID=$(printf "Test setting time to %02d:%02d, %s" $hh $mm $time_format)
local value=$(($hh * 256 + $mm))
if [[ $time_format == 24hr ]]
then
value=$((value + 32768))
fi
expect_pattern $X52_CLOCK_1_INDEX $(printf '%04x' $value)
$X52CLI time $hh $mm $time_format
verify_output
}
raw_date_test()
{
local dd=$1
local mm=$2
local yy=$3
local date_format=$4
case "$date_format" in
ddmmyy)
dd1=$dd
mm1=$mm
yy1=$yy
;;
mmddyy)
dd1=$mm
mm1=$dd
yy1=$yy
;;
yymmdd)
dd1=$yy
mm1=$mm
yy1=$dd
;;
esac
TEST_ID=$(printf "Test setting date in %s format to %02d-%02d-%02d" $date_format $dd1 $mm1 $yy1)
local date_value=$(printf '%04x' $(($mm1 * 256 + $dd1)))
local year_value=$(printf '%04x' $yy1)
expect_pattern \
$X52_CLOCK_DATE_INDEX $date_value \
$X52_CLOCK_YEAR_INDEX $year_value
$X52CLI date $dd $mm $yy $date_format
verify_output
}
# For all test cases, we want to assume that the local timezone
# is the same as UTC, as otherwise, it can cause havoc, depending
# on when and where the tests are run.
export TZ=UTC
for timezone in 'local' gmt
do
for time_format in 12hr 24hr
do
for date_format in ddmmyy mmddyy yymmdd
do
clock_test_utc $timezone $time_format $date_format
done
done
done
# For the offset test cases, x52cli reinitializes the internal data
# structure every time it is called, therefore, the timezone for clock
# 1 is automatically reset to UTC.
unset TZ
for clock in 2 3
do
for time_format in 12hr 24hr
do
# Run offset tests for every 30 minute offset from UTC
for offset in $(seq -1020 30 1020)
do
offset_test $clock $offset $time_format
done
done
done
# The raw time test cases are a limited set of tests, it simply runs for
# every minute from 00:00 through 00:59, then it runs for every hour from
# 00:00 through 23:00. The tests are run in both 12 hour and 24 hour mode.
for mm in $(seq 0 59)
do
for time_format in 12hr 24hr
do
raw_time_test 0 $mm $time_format
done
done
for hh in $(seq 0 23)
do
for time_format in 12hr 24hr
do
raw_time_test $hh 0 $time_format
done
done
# The raw date tests simply verify that the date February 1, year 3 is
# displayed correctly in all 3 date formats
for date_format in ddmmyy mmddyy yymmdd
do
raw_date_test 1 2 3 $date_format
done
verify_test_suite

View File

@ -1,36 +0,0 @@
#!/usr/bin/env bash
# Indicator (blink & shift) tests
#
# Copyright (C) 2012-2018 Nirenjan Krishnan (nirenjan@nirenjan.org)
#
# SPDX-License-Identifier: GPL-2.0-only WITH Classpath-exception-2.0
source $(dirname $0)/cli/common_infra.sh
TEST_SUITE_ID="libx52 indicator tests (blink & shift)"
indicator_test()
{
local indicator=$(echo $1 | tr a-z A-Z)
local state=$(echo $2 | tr a-z A-Z)
local index="\$X52_${indicator}_INDICATOR_INDEX"
local value="\$X52_INDICATOR_STATE_${state}"
TEST_ID="Test setting $indicator $state"
expect_pattern $(eval echo $index $value)
$X52CLI $indicator $state
verify_output
}
for indicator in blink shift
do
for state in on off
do
indicator_test $indicator $state
done
done
verify_test_suite

View File

@ -1,83 +0,0 @@
#!/usr/bin/env bash
# LED tests
#
# Copyright (C) 2012-2018 Nirenjan Krishnan (nirenjan@nirenjan.org)
#
# SPDX-License-Identifier: GPL-2.0-only WITH Classpath-exception-2.0
source $(dirname $0)/cli/common_infra.sh
TEST_SUITE_ID="libx52 LED state tests"
mono_led_test()
{
local led_ident=$(echo $1 | tr a-z A-Z)
local led_state=$2
local state=$(echo "\$X52_LED_${led_ident}_${led_state}" | tr a-z A-Z)
local TEST_ID="Test setting the $led_ident button $led_state"
expect_pattern $X52_LED_COMMAND_INDEX $(eval echo $state)
$X52CLI led $led_ident $led_state
verify_output
}
color_led_test()
{
local led_ident=$(echo $1 | tr a-z A-Z)
local led_color=$(echo $2 | tr A-Z a-z)
local led_r_state=off
local led_g_state=off
local TEST_ID="Test setting the $led_ident button to $led_color"
case $led_color in
'red')
led_r_state=on
;;
'green')
led_g_state=on
;;
'amber')
led_r_state=on
led_g_state=on
;;
'off')
;;
*)
echo "ERROR: Unknown ident" >&2
exit $EXIT_HARD_ERROR
;;
esac
led_r_state=$(echo "\$X52_LED_${led_ident}_red_${led_r_state}" | tr a-z A-Z)
led_g_state=$(echo "\$X52_LED_${led_ident}_green_${led_g_state}" | tr a-z A-Z)
expect_pattern \
$X52_LED_COMMAND_INDEX $(eval echo $led_r_state) \
$X52_LED_COMMAND_INDEX $(eval echo $led_g_state)
$X52CLI led $led_ident $led_color
verify_output
}
# Run Mono-color LED tests
for led in fire throttle
do
for state in on off
do
mono_led_test $led $state
done
done
# Run multi-color LED tests
for led in a b d e t1 t2 t3 pov clutch
do
for color in off red amber green
do
color_led_test $led $color
done
done
verify_test_suite

View File

@ -1,91 +0,0 @@
#!/usr/bin/env bash
# MFD tests
#
# Copyright (C) 2012-2018 Nirenjan Krishnan (nirenjan@nirenjan.org)
#
# SPDX-License-Identifier: GPL-2.0-only WITH Classpath-exception-2.0
source $(dirname $0)/cli/common_infra.sh
TEST_SUITE_ID="libx52 MFD text tests"
# Take in input as a string, and convert them to list of MFD set format
format_text()
{
local clear_index=$(eval echo $1)
local set_index=$(eval echo $2)
local input_string=$3
local output_list="$clear_index 0"
local count=0
while [[ ${#input_string} -gt 1 ]]
do
char1=${input_string:0:1}
char2=${input_string:1:1}
input_string=${input_string:2}
output_list="$output_list $set_index $(printf '%02x%02x' \'$char2 \'$char1)"
((count+=2))
# The library ignores strings longer than 16 characters
if [[ $count -eq 16 ]]
then
# Discard the rest of the input string
input_string=
fi
done
if [[ ${#input_string} -eq 1 ]]
then
# Add the remaining character, but pad with a space
output_list="$output_list $set_index $(printf '20%02x' \'$input_string)"
fi
echo $output_list
return 0
}
mfd_text_test()
{
local line=$1
local clear_index="\$X52_MFD_LINE_${line}_CLR_INDEX"
local set_index="\$X52_MFD_LINE_${line}_SET_INDEX"
local text="$2"
TEST_ID="Test setting MFD line $line to '$text'"
pattern=$(format_text $clear_index $set_index "$text")
expect_pattern $pattern
$X52CLI mfd $line "$text"
verify_output
}
for text in \
a \
ab \
abc \
abcd \
abcde \
abcdef \
abcdefg \
abcdefgh \
abcdefghi \
abcdefghij \
abcdefghijk \
abcdefghijkl \
abcdefghijklm \
abcdefghijklmn \
abcdefghijklmno \
abcdefghijklmnop \
abcdefghijklmnopq \
abcdefghijklmnopqr \
;
do
for line in 0 1 2
do
mfd_text_test $line "$text"
done
done
verify_test_suite

View File

@ -1,68 +0,0 @@
#!/usr/bin/env bash
# Timezone tests
#
# Copyright (C) 2020 Nirenjan Krishnan (nirenjan@nirenjan.org)
#
# SPDX-License-Identifier: GPL-2.0-only WITH Classpath-exception-2.0
source $(dirname $0)/cli/common_infra.sh
require_programs faketime
TEST_SUITE_ID="libx52 timezone tests"
# Use the America/Los_Angeles timezone
# Standard time is UTC-08:00, Daylight time is UTC-07:00
export TZ=America/Los_Angeles
# All timezone tests use DD-MM-YY and 12hr format
timezone_test()
{
local datetime="$1"
TEST_ID="Test setting clock to '$(date --date="$datetime")'"
local dd=$(date --date="$datetime" +%_d)
local mm=$(date --date="$datetime" +%_m)
local yy=$(date --date="$datetime" +%_y)
local hr=$(date --date="$datetime" +%_H)
local mn=$(date --date="$datetime" +%_M)
local off
if [[ "$(date --date="$datetime" +%Z)" == 'PDT' ]]
then
# Pacific Daylight Time
# Default offset for clocks 2 & 3 should be +420 minutes
off=420
else
# Pacific Standard time
# Default offset for clocks 2 & 3 should be +480 minutes
off=480
fi
local clock_value=$(($hr * 256 + $mn))
local date_value=$(($mm * 256 + $dd))
local year_value=$yy
expect_pattern \
$X52_CLOCK_DATE_INDEX $(printf '%04x' $date_value) \
$X52_CLOCK_YEAR_INDEX $(printf '%04x' $year_value) \
$X52_CLOCK_1_INDEX $(printf '%04x' $clock_value) \
$X52_CLOCK_2_INDEX $(printf '%04x' $off) \
$X52_CLOCK_3_INDEX $(printf '%04x' $off) \
faketime "$datetime" $X52CLI clock local 12hr ddmmyy
verify_output
}
# Check timezone test for 14:15:16 on the 13th day of every month from
# January 2017 to December 2019
for year in $(seq 2017 2019)
do
for month in $(seq 1 12)
do
timezone_test "$(printf '%d-%02d-13 14:15:16' $year $month)"
done
done
verify_test_suite

View File

@ -1,203 +0,0 @@
#!/bin/bash
# Common infrastructure for the test cases
#
# Copyright (C) 2012-2018 Nirenjan Krishnan (nirenjan@nirenjan.org)
#
# SPDX-License-Identifier: GPL-2.0-only WITH Classpath-exception-2.0
# Set up some command sequences
X52_LED_COMMAND_INDEX='00b8'
X52_LED_FIRE_ON='0101'
X52_LED_FIRE_OFF='0100'
X52_LED_A_RED_ON='0201'
X52_LED_A_RED_OFF='0200'
X52_LED_A_GREEN_ON='0301'
X52_LED_A_GREEN_OFF='0300'
X52_LED_B_RED_ON='0401'
X52_LED_B_RED_OFF='0400'
X52_LED_B_GREEN_ON='0501'
X52_LED_B_GREEN_OFF='0500'
X52_LED_D_RED_ON='0601'
X52_LED_D_RED_OFF='0600'
X52_LED_D_GREEN_ON='0701'
X52_LED_D_GREEN_OFF='0700'
X52_LED_E_RED_ON='0801'
X52_LED_E_RED_OFF='0800'
X52_LED_E_GREEN_ON='0901'
X52_LED_E_GREEN_OFF='0900'
X52_LED_T1_RED_ON='0a01'
X52_LED_T1_RED_OFF='0a00'
X52_LED_T1_GREEN_ON='0b01'
X52_LED_T1_GREEN_OFF='0b00'
X52_LED_T2_RED_ON='0c01'
X52_LED_T2_RED_OFF='0c00'
X52_LED_T2_GREEN_ON='0d01'
X52_LED_T2_GREEN_OFF='0d00'
X52_LED_T3_RED_ON='0e01'
X52_LED_T3_RED_OFF='0e00'
X52_LED_T3_GREEN_ON='0f01'
X52_LED_T3_GREEN_OFF='0f00'
X52_LED_POV_RED_ON='1001'
X52_LED_POV_RED_OFF='1000'
X52_LED_POV_GREEN_ON='1101'
X52_LED_POV_GREEN_OFF='1100'
X52_LED_CLUTCH_RED_ON='1201'
X52_LED_CLUTCH_RED_OFF='1200'
X52_LED_CLUTCH_GREEN_ON='1301'
X52_LED_CLUTCH_GREEN_OFF='1300'
X52_LED_THROTTLE_ON='1401'
X52_LED_THROTTLE_OFF='1400'
X52_MFD_BRIGHTNESS_INDEX='00b1'
X52_LED_BRIGHTNESS_INDEX='00b2'
X52_BLINK_INDICATOR_INDEX='00b4'
X52_SHIFT_INDICATOR_INDEX='00fd'
X52_INDICATOR_STATE_ON='0051'
X52_INDICATOR_STATE_OFF='0050'
X52_CLOCK_1_INDEX='00c0'
X52_CLOCK_2_INDEX='00c1'
X52_CLOCK_3_INDEX='00c2'
X52_CLOCK_DATE_INDEX='00c4'
X52_CLOCK_YEAR_INDEX='00c8'
X52_MFD_LINE_0_SET_INDEX='00d1'
X52_MFD_LINE_1_SET_INDEX='00d2'
X52_MFD_LINE_2_SET_INDEX='00d4'
X52_MFD_LINE_0_CLR_INDEX='00d9'
X52_MFD_LINE_1_CLR_INDEX='00da'
X52_MFD_LINE_2_CLR_INDEX='00dc'
find_programs()
{
# Tests and distcheck do not work on OSX, skip the tests
if [[ $(uname -s) == [Dd]arwin* ]]
then
echo "1..0 # skip Tests not supported on OSX"
exit 0
fi
# Find the X52cli script
X52CLI=$(find .. -path '*/x52cli' -perm -+x)
if [[ -z "$X52CLI" ]]
then
exit 1
fi
# Find the x52test_log_actions program
X52LOGACT=$(find .. -path '*/x52test_log_actions' -perm -+x)
if [[ -z "$X52LOGACT" ]]
then
exit 1
fi
# Find the x52test_create_device_list program
X52DEVLIST=$(find .. -path '*/x52test_create_device_list' -perm -+x)
if [[ -z "$X52DEVLIST" ]]
then
exit 1
fi
}
# This is for additional programs that are not needed by every test case
require_programs()
{
local skip=false
for prog in "$@"
do
if ! command -v "$prog"
then
echo "1..0 # skip Required program '$prog' not found"
skip=true
fi
done
if $skip
then
exit 0
fi
}
setup_preload()
{
# Find the libusb stub library
LIBUSB=$(find .. -name 'libusbx52.so.*.*.*' -type f)
if [[ -z "$LIBUSB" ]]
then
exit 1
fi
export LD_PRELOAD=$(realpath $LIBUSB)
}
setup_test()
{
export LIBUSBX52_DEVICE_LIST=$(mktemp)
EXPECTED_OUTPUT=$(mktemp)
OBSERVED_OUTPUT=$(mktemp)
trap "rm -f $EXPECTED_OUTPUT $OBSERVED_OUTPUT $LIBUSBX52_DEVICE_LIST" EXIT
$X52DEVLIST 06a3 0762
TEST_COUNT=0
TEST_PASS=0
TEST_FAIL=0
}
expect_pattern()
{
TEST_NUM=$((TEST_NUM + 1))
# Save pattern to expected output file
export LIBUSBX52_OUTPUT_DATA=$EXPECTED_OUTPUT
$X52LOGACT $@
# Save actual API calls to observed output file
export LIBUSBX52_OUTPUT_DATA=$OBSERVED_OUTPUT
}
verify_output()
{
TEST_COUNT=$(($TEST_COUNT + 1))
if diff -q $EXPECTED_OUTPUT $OBSERVED_OUTPUT
then
echo "ok $TEST_COUNT $TEST_ID"
TEST_PASS=$(($TEST_PASS + 1))
else
echo "not ok $TEST_COUNT $TEST_ID"
echo '# Expected:'
echo '# ========='
sed 's/^/#\t/' $EXPECTED_OUTPUT
echo '#'
echo '# Observed:'
echo '# ========='
sed 's/^/#\t/' $OBSERVED_OUTPUT
TEST_FAIL=$(($TEST_FAIL + 1))
fi
}
verify_test_suite()
{
local sep='--------'
sep="$sep$sep"
sep="$sep$sep"
sep="$sep$sep"
echo '#' $sep
echo '#' $TEST_SUITE_ID
echo '#' $sep
echo -e "# Total Tests:\t$TEST_COUNT"
echo -e "# Tests Passed:\t$TEST_PASS"
echo -e "# Tests Failed:\t$TEST_FAIL"
echo '#' $sep
echo "1..$TEST_COUNT"
}
set -e
find_programs
setup_test
setup_preload

177
cli/test_x52_cli.c 100644
View File

@ -0,0 +1,177 @@
/*
* Saitek X52 Pro MFD & LED driver - CLI test harness
*
* Copyright (C) 2021 Nirenjan Krishnan (nirenjan@nirenjan.org)
*
* SPDX-License-Identifier: GPL-2.0-only WITH Classpath-exception-2.0
*/
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <setjmp.h>
#include <cmocka.h>
#include "libx52.h"
extern int run_main(int argc, char **argv);
/* Wrapper functions for libx52 */
int libx52_init(libx52_device **dev)
{
*dev = NULL;
return LIBX52_SUCCESS;
}
int libx52_connect(libx52_device *dev)
{
return LIBX52_SUCCESS;
}
int libx52_update(libx52_device *dev)
{
return LIBX52_SUCCESS;
}
void libx52_exit(libx52_device *dev)
{
}
const char *libx52_strerror(libx52_error_code rc)
{
return "";
}
int libx52_set_text(libx52_device *x52, uint8_t line, const char *text, uint8_t length)
{
function_called();
assert_ptr_equal(x52, NULL);
check_expected(line);
check_expected(text);
check_expected(length);
return mock();
}
int libx52_set_led_state(libx52_device *x52, libx52_led_id id, libx52_led_state state)
{
function_called();
assert_ptr_equal(x52, NULL);
check_expected(id);
check_expected(state);
return mock();
}
int libx52_set_clock(libx52_device *x52, time_t time, int local)
{
function_called();
assert_ptr_equal(x52, NULL);
check_expected(time);
check_expected(local);
return mock();
}
int libx52_set_clock_timezone(libx52_device *x52, libx52_clock_id clock, int offset)
{
function_called();
assert_ptr_equal(x52, NULL);
check_expected(clock);
check_expected(offset);
return mock();
}
int libx52_set_clock_format(libx52_device *x52, libx52_clock_id clock, libx52_clock_format format)
{
function_called();
assert_ptr_equal(x52, NULL);
check_expected(clock);
check_expected(format);
return mock();
}
int libx52_set_time(libx52_device *x52, uint8_t hour, uint8_t minute)
{
function_called();
assert_ptr_equal(x52, NULL);
check_expected(hour);
check_expected(minute);
return mock();
}
int libx52_set_date(libx52_device *x52, uint8_t dd, uint8_t mm, uint8_t yy)
{
function_called();
assert_ptr_equal(x52, NULL);
check_expected(dd);
check_expected(mm);
check_expected(yy);
return mock();
}
int libx52_set_date_format(libx52_device *x52, libx52_date_format format)
{
function_called();
assert_ptr_equal(x52, NULL);
check_expected(format);
return mock();
}
int libx52_set_brightness(libx52_device *x52, uint8_t mfd, uint16_t brightness)
{
function_called();
assert_ptr_equal(x52, NULL);
check_expected(mfd);
check_expected(brightness);
return mock();
}
int libx52_set_shift(libx52_device *x52, uint8_t state)
{
function_called();
assert_ptr_equal(x52, NULL);
check_expected(state);
return mock();
}
int libx52_set_blink(libx52_device *x52, uint8_t state)
{
function_called();
assert_ptr_equal(x52, NULL);
check_expected(state);
return mock();
}
int libx52_vendor_command(libx52_device *x52, uint16_t index, uint16_t value)
{
function_called();
assert_ptr_equal(x52, NULL);
check_expected(index);
check_expected(value);
return mock();
}
#include "test_x52_cli_tests.c"
#define TEST_LIST
const struct CMUnitTest tests[] = {
#include "test_x52_cli_tests.c"
};
int main(int argc, char **argv)
{
cmocka_set_message_output(CM_OUTPUT_TAP);
cmocka_run_group_tests(tests, NULL, NULL);
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/* /*
* Saitek X52 Pro MFD & LED driver * Saitek X52 Pro MFD & LED driver
* *
* Copyright (C) 2015 Nirenjan Krishnan (nirenjan@nirenjan.org) * Copyright (C) 2015-2021 Nirenjan Krishnan (nirenjan@nirenjan.org)
* *
* SPDX-License-Identifier: GPL-2.0-only WITH Classpath-exception-2.0 * SPDX-License-Identifier: GPL-2.0-only WITH Classpath-exception-2.0
*/ */
@ -469,7 +469,11 @@ static void do_help(const struct command_handler *cmd)
} }
} }
#ifdef X52_CLI_TESTING
int run_main(int argc, char **argv)
#else
int main(int argc, char **argv) int main(int argc, char **argv)
#endif
{ {
libx52_device *x52; libx52_device *x52;
struct string_map result; struct string_map result;