Skip to content

Commit 2608d97

Browse files
committed
test: Simplify api-test app
1 parent 897ccc8 commit 2608d97

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+952
-1215
lines changed

.github/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
FROM ubuntu:24.04
32

43
ENV DEBIAN_FRONTEND=noninteractive
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
# vim: ts=4
33

4-
# Copyright 2025 Comcast Cable Communications Management, LLC
4+
# Copyright 2026 Comcast Cable Communications Management, LLC
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@ done
5757
[[ -e "$specOpenRpc" ]] || die "OpenRPC spec '$specOpenRpc' not found"
5858
[[ -e "$specAppOpenRpc" ]] || die "OpenRPC App spec '$specAppOpenRpc' not found"
5959
[[ -e "$mockConfig" ]] || die "Config '$mockConfig' not found"
60-
[[ -e "$testExe" ]] || die "Executable for cpp_test '$testExe' not found"
60+
[[ -e "$testExe" ]] || die "Executable '$testExe' not found"
6161

6262
cfgFile=$mockPath/server/src/.mf.config.json
6363

@@ -93,13 +93,10 @@ while ! nc -z localhost $mockPort >/dev/null 2>&1; do
9393
sleep 1
9494
done
9595

96-
echo "Starting cpp_test with -mock and -auto flags"
96+
echo "Starting '$(basename "$testExe") --mock --auto'"
9797
cd "$(dirname "$testExe")"
98-
99-
# Capture exit code without triggering set -e
10098
set +e
101-
"./$(basename "$testExe")" -mock -auto
99+
"./$(basename "$testExe")" --mock --auto
102100
exitCode=$?
103-
set -e
104101

105102
exit $exitCode

.github/workflows/ci.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ jobs:
269269
--app-openrpc /workspace/docs/openrpc/the-spec/firebolt-app-open-rpc.json \
270270
--test-exe /workspace/build/test/ctApp
271271
272-
cpp_demo_tests:
272+
api_test_app:
273273
permissions:
274274
contents: read
275275
packages: read
@@ -292,7 +292,7 @@ jobs:
292292
name: build-dir
293293
path: ${{ github.workspace }}/build
294294

295-
- name: Build api_test_app standalone
295+
- name: Build api-test-app standalone
296296
run: |
297297
docker run --rm --user "$(id -u):$(id -g)" -v ${{ github.workspace }}:/workspace ${{ needs.build_docker.outputs.image_tag }} \
298298
bash -c " \
@@ -314,16 +314,13 @@ jobs:
314314
path: ${{ env.MOCK_PATH }}
315315
key: ${{ runner.os }}-mock-${{ steps.setup-mock.outputs.deps_cache_key }}
316316

317-
- name: Run Demo with mock server
317+
- name: Run api-test-app with mock server
318318
run: |
319-
chmod +x ${{ github.workspace }}/test/api_test_app/build/api_test_app
319+
chmod +x ${{ github.workspace }}/test/api_test_app/build/api-test-app
320320
docker run --rm --user "$(id -u):$(id -g)" -v ${{ github.workspace }}:/workspace -v ${{ env.MOCK_PATH }}:/mock ${{ needs.build_docker.outputs.image_tag }} \
321-
./.github/scripts/run-cpp-test.sh \
321+
./.github/scripts/run-api-test-app.sh \
322322
--mock /mock \
323323
--config /workspace/.github/mock-firebolt/config.json \
324324
--openrpc /workspace/docs/openrpc/the-spec/firebolt-open-rpc.json \
325325
--app-openrpc /workspace/docs/openrpc/the-spec/firebolt-app-open-rpc.json \
326-
--test-exe /workspace/test/api_test_app/build/api_test_app
327-
328-
# Removed artifact upload step for api_test_app binary as per PR feedback
329-
326+
--test-exe /workspace/test/api_test_app/build/api-test-app

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,3 @@ endif()
101101
if (ENABLE_TESTS)
102102
add_subdirectory(test)
103103
endif()
104-

test/api_test_app/CMakeLists.txt

Lines changed: 12 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
if (NOT CMAKE_PROJECT_NAME)
1818
cmake_minimum_required(VERSION 3.10)
19-
project(api_test_app CXX)
19+
project(api-test-app CXX)
2020

2121
# Read SYSROOT_PATH from environment if not set as CMake variable
2222
if (NOT SYSROOT_PATH AND DEFINED ENV{SYSROOT_PATH})
@@ -30,7 +30,7 @@ if (NOT CMAKE_PROJECT_NAME)
3030

3131
# Add paths for finding installed packages
3232
if (SYSROOT_PATH)
33-
list(APPEND CMAKE_PREFIX_PATH
33+
list(APPEND CMAKE_PREFIX_PATH
3434
"${SYSROOT_PATH}/usr/lib/cmake"
3535
"${SYSROOT_PATH}/usr/share/cmake"
3636
)
@@ -40,117 +40,53 @@ if (NOT CMAKE_PROJECT_NAME)
4040
"${SYSROOT_PATH}/tools/cmake"
4141
)
4242
endif()
43-
44-
# Add standard system paths for finding packages
45-
list(APPEND CMAKE_PREFIX_PATH
46-
"/usr/local"
47-
"/usr"
48-
)
43+
4944
endif ()
5045

51-
set(API_TEST_APP api_test_app)
46+
set(API_TEST_APP api-test-app)
5247

5348
message("Setup ${API_TEST_APP}")
5449

5550
add_compile_options(-Wall -Wextra -Wpedantic)
5651

57-
# Generate header file with embedded JSON content
58-
file(READ "../../docs/openrpc/the-spec/firebolt-open-rpc.json" JSON_CONTENT)
59-
configure_file(
60-
cpp/firebolt-open-rpc.json.in
61-
"${CMAKE_BINARY_DIR}/generated/firebolt-open-rpc_json.h"
62-
@ONLY
63-
)
64-
65-
file(GLOB SOURCES CONFIGURE_DEPENDS cpp/*.cpp)
52+
file(GLOB SOURCES CONFIGURE_DEPENDS apis/*.cpp)
6653

6754
add_executable(${API_TEST_APP}
6855
main.cpp
56+
utils.cpp
6957
${SOURCES}
7058
)
7159

7260
if (ENABLE_DEMO_APP)
73-
# Building as part of the main project - dependencies already available
74-
if(TARGET nlohmann_json_schema_validator::validator)
75-
set(NLOHMANN_VALIDATOR_TARGET nlohmann_json_schema_validator::validator)
76-
else()
77-
set(NLOHMANN_VALIDATOR_TARGET nlohmann_json_schema_validator)
78-
endif()
79-
if(TARGET CURL::libcurl)
80-
set(CURL_TARGET CURL::libcurl)
81-
else()
82-
set(CURL_TARGET curl)
83-
endif()
84-
if(TARGET Threads::Threads)
85-
set(THREADS_TARGET Threads::Threads)
86-
else()
87-
set(THREADS_TARGET pthread)
88-
endif()
8961
target_link_libraries(${API_TEST_APP}
9062
PRIVATE
9163
FireboltClient
9264
nlohmann_json::nlohmann_json
93-
${NLOHMANN_VALIDATOR_TARGET}
94-
${CURL_TARGET}
95-
${THREADS_TARGET}
9665
)
97-
set(SOURCE_ROOT ${CMAKE_SOURCE_DIR})
98-
target_link_directories(${API_TEST_APP} PRIVATE $ENV{SYSROOT_PATH}/usr/lib)
9966
else()
100-
# Building standalone - find all installed dependencies
10167
find_package(FireboltTransport CONFIG REQUIRED)
10268
find_package(FireboltClient CONFIG REQUIRED)
103-
find_package(nlohmann_json REQUIRED)
104-
find_package(nlohmann_json_schema_validator CONFIG REQUIRED)
105-
find_package(CURL REQUIRED)
106-
find_package(Threads REQUIRED)
107-
if(TARGET nlohmann_json_schema_validator::validator)
108-
set(NLOHMANN_VALIDATOR_TARGET nlohmann_json_schema_validator::validator)
109-
else()
110-
set(NLOHMANN_VALIDATOR_TARGET nlohmann_json_schema_validator)
111-
endif()
112-
if(TARGET CURL::libcurl)
113-
set(CURL_TARGET CURL::libcurl)
114-
else()
115-
set(CURL_TARGET curl)
116-
endif()
117-
if(TARGET Threads::Threads)
118-
set(THREADS_TARGET Threads::Threads)
119-
else()
120-
set(THREADS_TARGET pthread)
121-
endif()
12269
target_link_libraries(${API_TEST_APP}
12370
PRIVATE
12471
FireboltTransport::FireboltTransport
12572
FireboltClient::FireboltClient
126-
nlohmann_json::nlohmann_json
127-
${NLOHMANN_VALIDATOR_TARGET}
128-
${CURL_TARGET}
129-
${THREADS_TARGET}
13073
)
131-
set(SOURCE_ROOT ${CMAKE_SOURCE_DIR}/../..)
132-
endif ()
74+
endif()
13375

13476
target_include_directories(${API_TEST_APP}
13577
PRIVATE
136-
137-
$<BUILD_INTERFACE:${SOURCE_ROOT}/include/>
138-
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/src/>
139-
$<BUILD_INTERFACE:${SOURCE_ROOT}/test/>
140-
$<BUILD_INTERFACE:${SOURCE_ROOT}/src/>
141-
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/generated>
78+
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/src>
79+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../src>
80+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
81+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/apis>
14282
)
14383

144-
add_compile_definitions(UT_OPEN_RPC_FILE="firebolt-open-rpc.json")
145-
14684
set_target_properties(${API_TEST_APP} PROPERTIES
14785
CXX_STANDARD 17
14886
CXX_STANDARD_REQUIRED YES
149-
BUILD_RPATH "${CMAKE_BINARY_DIR}/src"
150-
INSTALL_RPATH "$ORIGIN/../src"
15187
)
15288

15389
install(
15490
TARGETS ${API_TEST_APP}
15591
DESTINATION bin
156-
)
92+
)
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* Copyright 2026 Comcast Cable Communications Management, LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
*/
18+
19+
#include "accessibilityDemo.h"
20+
#include <firebolt/firebolt.h>
21+
#include <ios>
22+
#include <iostream>
23+
#include <string>
24+
#include <vector>
25+
26+
using namespace Firebolt;
27+
using namespace Firebolt::Accessibility;
28+
29+
AccessibilityDemo::AccessibilityDemo()
30+
: DemoBase("Accessibility")
31+
{
32+
methods_.push_back("Accessibility.audioDescription");
33+
methods_.push_back("Accessibility.closedCaptionsSettings");
34+
methods_.push_back("Accessibility.highContrastUI");
35+
methods_.push_back("Accessibility.voiceGuidanceSettings");
36+
}
37+
38+
void AccessibilityDemo::runOption(const std::string& method)
39+
{
40+
std::cout << "Running Accessibility method: " << method << std::endl;
41+
42+
if (method == "Accessibility.closedCaptionsSettings")
43+
{
44+
auto r = Firebolt::IFireboltAccessor::Instance().AccessibilityInterface().closedCaptionsSettings();
45+
if (succeed(r))
46+
{
47+
std::cout << "Closed Captions Settings - Enabled: " << std::boolalpha << r->enabled << std::endl;
48+
}
49+
}
50+
else if (method == "Accessibility.audioDescription")
51+
{
52+
auto r = Firebolt::IFireboltAccessor::Instance().AccessibilityInterface().audioDescription();
53+
if (succeed(r))
54+
{
55+
std::cout << "Audio Description Enabled: " << std::boolalpha << *r << std::endl;
56+
}
57+
}
58+
else if (method == "Accessibility.highContrastUI")
59+
{
60+
auto r = Firebolt::IFireboltAccessor::Instance().AccessibilityInterface().highContrastUI();
61+
if (succeed(r))
62+
{
63+
std::cout << "High Contrast UI Enabled: " << std::boolalpha << *r << std::endl;
64+
}
65+
}
66+
else if (method == "Accessibility.voiceGuidanceSettings")
67+
{
68+
auto r = Firebolt::IFireboltAccessor::Instance().AccessibilityInterface().voiceGuidanceSettings();
69+
if (succeed(r))
70+
{
71+
std::cout << "Voice Guidance Settings - Enabled: " << std::boolalpha << r->enabled << ", Rate: " << r->rate
72+
<< std::endl;
73+
}
74+
}
75+
}

test/api_test_app/cpp/accessibilityDemo.h renamed to test/api_test_app/apis/accessibilityDemo.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@
1818

1919
#pragma once
2020

21-
#include "fireboltDemoBase.h"
21+
#include "utils.h"
2222
#include <string>
23-
#include <vector>
2423

25-
class AccessibilityDemo : public FireboltDemoBase
24+
class AccessibilityDemo : public DemoBase
2625
{
2726
public:
2827
AccessibilityDemo();
2928
~AccessibilityDemo() = default;
30-
void runOption(const int index);
29+
void runOption(const std::string& method) override;
3130
};

test/api_test_app/cpp/advertisingDemo.cpp renamed to test/api_test_app/apis/advertisingDemo.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include "advertisingDemo.h"
20+
#include <firebolt/firebolt.h>
2021
#include <iostream>
2122
#include <string>
2223
#include <vector>
@@ -25,24 +26,21 @@ using namespace Firebolt;
2526
using namespace Firebolt::Advertising;
2627

2728
AdvertisingDemo::AdvertisingDemo()
28-
: FireboltDemoBase()
29+
: DemoBase("Advertising")
2930
{
30-
methodsFromRpc("Advertising");
31+
methods_.push_back("Advertising.advertisingId");
3132
}
3233

33-
void AdvertisingDemo::runOption(const int index)
34+
void AdvertisingDemo::runOption(const std::string& method)
3435
{
35-
std::string key = itemDescriptions_[index].name;
36-
37-
if (key == "Advertising.advertisingId")
36+
if (method == "Advertising.advertisingId")
3837
{
39-
Result<Ifa> result = Firebolt::IFireboltAccessor::Instance().AdvertisingInterface().advertisingId();
40-
if (validateResult(result))
38+
auto r = Firebolt::IFireboltAccessor::Instance().AdvertisingInterface().advertisingId();
39+
if (succeed(r))
4140
{
42-
Ifa ifa = result.value();
43-
std::cout << "IFA: " << ifa.ifa << std::endl;
44-
std::cout << "IFA Type: " << ifa.ifa_type << std::endl;
45-
std::cout << "LMT: " << ifa.lmt << std::endl;
41+
std::cout << "IFA: " << r->ifa << std::endl;
42+
std::cout << "IFA Type: " << r->ifa_type << std::endl;
43+
std::cout << "LMT: " << r->lmt << std::endl;
4644
}
4745
}
4846
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@
1818

1919
#pragma once
2020

21-
#include "fireboltDemoBase.h"
21+
#include "utils.h"
2222
#include <string>
23-
#include <vector>
2423

25-
class AdvertisingDemo : public FireboltDemoBase
24+
class AdvertisingDemo : public DemoBase
2625
{
2726
public:
2827
AdvertisingDemo();
2928
~AdvertisingDemo() = default;
30-
void runOption(const int index);
29+
void runOption(const std::string& method) override;
3130
};

0 commit comments

Comments
 (0)