diff options
author | dvdli <dvdli@google.com> | 2020-12-01 14:10:34 +0800 |
---|---|---|
committer | dvdli <dvdli@google.com> | 2020-12-01 14:10:34 +0800 |
commit | ee672bb4b3919ba8e411ca5bba95e22b288f2831 (patch) | |
tree | 54d62028c60b04cf44f2d748c8b56a558da7e2d8 | |
parent | b59e5e1b11a4cb3919ac0c7d1fffb4e7452424e0 (diff) |
add instructions to run tests and fix typo
-rw-r--r-- | README.md | 38 | ||||
-rw-r--r-- | tests/include/pcm_test_device.h | 6 |
2 files changed, 41 insertions, 3 deletions
@@ -63,3 +63,41 @@ man libtinyalsa-pcm man libtinyalsa-mixer ``` +### Test + +To test libtinyalsa, please follow the instructions, + +#### Setup Bazel build environment + +Visit [here](https://docs.bazel.build/versions/3.7.0/install.html) to get more info to setup Bazel environment. + +#### Insert loopback devices + +The test program does pcm_* operations on loopback devices. You have to insert loopback devices after your system boots up. + +``` +sudo modprobe snd-aloop +sudo chmod 777 /dev/snd/* +``` + +#### Run test program + +``` +bazel test //:tinyalsa_tests --test_output=all +``` + +The default playback device is hw:2,0 and the default capture device is hw:2,1. If your loopback devices are not hw:2,0 and hw:2,1, you can specify the loopback device. + +``` +bazel test //:tinyalsa_tests --test_output=all \ + --copt=-DTEST_LOOPBACK_CARD=[loopback card] \ + --copt=-DTEST_LOOPBACK_PLAYBACK_DEVICE=[loopback playback device] \ + --copt=-DTEST_LOOPBACK_CAPTURE_DEVICE=[loopback capture device] +``` + +#### Generate coverage report + +``` +bazel coverage //:tinyalsa_tests --combined_report=lcov --test_output=all +genhtml bazel-out/_coverage/_coverage_report.dat -o tinyalsa_tests_coverage +``` diff --git a/tests/include/pcm_test_device.h b/tests/include/pcm_test_device.h index f6e7807..2df7c93 100644 --- a/tests/include/pcm_test_device.h +++ b/tests/include/pcm_test_device.h @@ -36,8 +36,8 @@ namespace testing { #define TEST_LOOPBACK_CARD 2 #endif -#ifndef TEST_LOOPBACK_PALYBACK_DEVICE -#define TEST_LOOPBACK_PALYBACK_DEVICE 0 +#ifndef TEST_LOOPBACK_PLAYBACK_DEVICE +#define TEST_LOOPBACK_PLAYBACK_DEVICE 0 #endif #ifndef TEST_LOOPBACK_CAPTURE_DEVICE @@ -45,7 +45,7 @@ namespace testing { #endif constexpr unsigned int kLoopbackCard = TEST_LOOPBACK_CARD; -constexpr unsigned int kLoopbackPlaybackDevice = TEST_LOOPBACK_PALYBACK_DEVICE; +constexpr unsigned int kLoopbackPlaybackDevice = TEST_LOOPBACK_PLAYBACK_DEVICE; constexpr unsigned int kLoopbackCaptureDevice = TEST_LOOPBACK_CAPTURE_DEVICE; } // namespace testing |