Skip to content

Commit

Permalink
Increase test coverage by adding bluealsa-cli test
Browse files Browse the repository at this point in the history
  • Loading branch information
arkq committed Nov 27, 2022
1 parent 0959403 commit ec334d5
Show file tree
Hide file tree
Showing 8 changed files with 323 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,15 @@ jobs:
working-directory: ${{ github.workspace }}/build
run: |
${{ github.workspace }}/configure \
--disable-aplay \
--enable-aac \
--enable-faststream \
--enable-mp3lame \
--enable-mpg123 \
--enable-msbc \
--enable-ofono \
--enable-upower \
--enable-cli \
--enable-test
- name: Build
working-directory: ${{ github.workspace }}/build
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/codecov-report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
--enable-msbc \
--enable-ofono \
--enable-upower \
--enable-cli \
--enable-test \
--with-coverage
- name: Generate Coverage Report
Expand Down
4 changes: 2 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# BlueALSA - Makefile.am
# Copyright (c) 2016-2021 Arkadiusz Bokowy
# Copyright (c) 2016-2022 Arkadiusz Bokowy

ACLOCAL_AMFLAGS = -I m4
SUBDIRS = misc src utils
Expand All @@ -15,7 +15,7 @@ endif
if WITH_COVERAGE
cov:
$(MAKE) $(AM_MAKEFLAGS) check CFLAGS="$(CFLAGS) -O0 --coverage"
$(LCOV) --capture -d src -d test --exclude '/usr/*' --exclude "*/test/*" -o cov.info
$(LCOV) --capture -d src -d utils -d test --exclude '/usr/*' --exclude "*/test/*" -o cov.info
$(GENHTML) -o coverage -t $(PACKAGE) cov.info
clean-local:
find $(top_builddir) -name "*.gcno" -delete
Expand Down
5 changes: 5 additions & 0 deletions test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ TESTS += test-msbc
check_PROGRAMS += test-msbc
endif

if ENABLE_CLI
TESTS += test-utils-cli
check_PROGRAMS += test-utils-cli
endif

check_LTLIBRARIES = \
aloader.la
aloader_la_LDFLAGS = \
Expand Down
10 changes: 4 additions & 6 deletions test/inc/server.inc
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ static void *spawn_bluealsa_server_stderr_proxy(void *userdata) {
return NULL;
}

/* path with the bluealsa-mock binary */
char *bluealsa_mock_path = ".";
/**
* Full path to the bluealsa-mock executable. */
char bluealsa_mock_path[256] = "bluealsa-mock";

/**
* Spawn bluealsa server mock.
Expand Down Expand Up @@ -143,9 +144,6 @@ pid_t spawn_bluealsa_server(const char *service, bool wait_for_ready, ...) {

va_end(ap);

char path[256];
sprintf(path, "%s/bluealsa-mock", bluealsa_mock_path);

int fds[2];
if (pipe(fds) == -1)
return -1;
Expand All @@ -155,7 +153,7 @@ pid_t spawn_bluealsa_server(const char *service, bool wait_for_ready, ...) {
dup2(fds[1], 2);
close(fds[0]);
close(fds[1]);
execv(path, argv);
execv(bluealsa_mock_path, argv);
}

close(fds[1]);
Expand Down
5 changes: 2 additions & 3 deletions test/test-alsa-ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,9 @@ START_TEST(test_alsa_high_level_control_interface) {
int main(int argc, char *argv[], char *envp[]) {
preload(argc, argv, envp, ".libs/aloader.so");

/* test-alsa-ctl and bluealsa-mock shall
* be placed in the same directory */
char *argv_0 = strdup(argv[0]);
bluealsa_mock_path = dirname(argv_0);
snprintf(bluealsa_mock_path, sizeof(bluealsa_mock_path),
"%s/bluealsa-mock", dirname(argv_0));

Suite *s = suite_create(__FILE__);
TCase *tc = tcase_create(__FILE__);
Expand Down
5 changes: 2 additions & 3 deletions test/test-alsa-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1040,10 +1040,9 @@ int main(int argc, char *argv[], char *envp[]) {
return 1;
}

/* test-alsa-pcm and bluealsa-mock shall
* be placed in the same directory */
char *argv_0 = strdup(argv[0]);
bluealsa_mock_path = dirname(argv_0);
snprintf(bluealsa_mock_path, sizeof(bluealsa_mock_path),
"%s/bluealsa-mock", dirname(argv_0));

if (argc == optind) {
run_capture = true;
Expand Down
Loading

0 comments on commit ec334d5

Please sign in to comment.