test: regression test initialized
The general test leverages the GoogleTest framework and will later serve as an integration test. The test exclusively executes libbladeRF_test_open in this commit.
This commit is contained in:
parent
686587fee4
commit
b2bfa13ebf
4 changed files with 130 additions and 2 deletions
|
|
@ -1,4 +1,4 @@
|
|||
cmake_minimum_required(VERSION 2.8.12)
|
||||
cmake_minimum_required(VERSION 3.9)
|
||||
|
||||
add_subdirectory(test_async)
|
||||
add_subdirectory(test_bootloader_recovery)
|
||||
|
|
@ -23,3 +23,4 @@ add_subdirectory(test_unused_sync)
|
|||
add_subdirectory(test_version)
|
||||
add_subdirectory(test_digital_loopback)
|
||||
add_subdirectory(test_interleaver)
|
||||
add_subdirectory(test_general)
|
||||
|
|
|
|||
37
host/libraries/libbladeRF_test/test_general/CMakeLists.txt
Normal file
37
host/libraries/libbladeRF_test/test_general/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
project(libbladeRF_test_general
|
||||
VERSION 3.9
|
||||
LANGUAGES CXX)
|
||||
|
||||
include(GoogleTest)
|
||||
enable_testing()
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
googletest
|
||||
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
|
||||
)
|
||||
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
|
||||
set(INCLUDES
|
||||
${libbladeRF_SOURCE_DIR}/include
|
||||
${libbladeRF_SOURCE_DIR}/src
|
||||
${BLADERF_HOST_COMMON_INCLUDE_DIRS}
|
||||
)
|
||||
include_directories(${INCLUDES})
|
||||
|
||||
set(SRC
|
||||
src/main.cxx
|
||||
${BLADERF_HOST_COMMON_SOURCE_DIR}/log.c
|
||||
${BLADERF_HOST_COMMON_SOURCE_DIR}/conversions.c
|
||||
)
|
||||
add_executable(${PROJECT_NAME} ${SRC})
|
||||
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
libbladerf_shared
|
||||
gtest_main
|
||||
)
|
||||
|
||||
gtest_discover_tests(${PROJECT_NAME})
|
||||
89
host/libraries/libbladeRF_test/test_general/src/main.cxx
Normal file
89
host/libraries/libbladeRF_test/test_general/src/main.cxx
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* This file is part of the bladeRF project:
|
||||
* http://www.github.com/nuand/bladeRF
|
||||
*
|
||||
* Copyright (C) 2023 Nuand LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "conversions.h"
|
||||
#include "log.h"
|
||||
#include <cstdlib>
|
||||
#include <getopt.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <libbladeRF.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define TEST_BLADERF device
|
||||
int status = 0;
|
||||
|
||||
TEST(TEST_BLADERF, open) {
|
||||
status = std::system("./output/libbladeRF_test_open");
|
||||
ASSERT_EQ(0, status);
|
||||
}
|
||||
|
||||
#define OPTARG "v:h"
|
||||
static struct option long_options[] = {
|
||||
{ "verbosity", required_argument, NULL, 'v' },
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ NULL, 0, NULL, 0 },
|
||||
};
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
bool ok = true;
|
||||
int opt = 0;
|
||||
int opt_ind = 0;
|
||||
bladerf_log_level log_level;
|
||||
|
||||
while (opt != -1) {
|
||||
opt = getopt_long(argc, argv, OPTARG, long_options, &opt_ind);
|
||||
|
||||
switch (opt) {
|
||||
case 'v':
|
||||
log_level = str2loglevel(optarg, &ok);
|
||||
if (!ok) {
|
||||
fprintf(stderr, "Invalid log level: %s\n", optarg);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
bladerf_log_set_verbosity(log_level);
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
printf("Usage: %s [options]\n", argv[0]);
|
||||
printf(" -v, --verbosity <l> Set libbladeRF verbosity level.\n");
|
||||
printf(" -h, --help Show this text.\n");
|
||||
printf("\n");
|
||||
printf(" --gtest_list_tests List all available tests without running them.\n");
|
||||
printf(" --gtest_filter=<filter> Run only the tests matching the filter.\n");
|
||||
printf(" Example filters: \"libbladeRF*\", \"hdl*\", \"synthesis*\"\n");
|
||||
printf(" --gtest_also_run_disabled_tests Run only the tests matching the filter.\n");
|
||||
printf(" --gtest_output=\"json\" Generates JSON report of test run.\n");
|
||||
printf("\n");
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
@ -100,6 +100,7 @@ int main(int argc, char *argv[])
|
|||
if (status != 0) {
|
||||
fprintf(stderr, "Failed to open device: %s\n",
|
||||
bladerf_strerror(status));
|
||||
return EXIT_FAILURE;
|
||||
} else {
|
||||
usleep(wait);
|
||||
bladerf_close(dev);
|
||||
|
|
@ -108,5 +109,5 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue