summaryrefslogtreecommitdiff
path: root/tests/dev
diff options
context:
space:
mode:
authorisaki <isaki@NetBSD.org>2020-03-25 13:07:04 +0000
committerisaki <isaki@NetBSD.org>2020-03-25 13:07:04 +0000
commit1ecea5d09f10df028e7e33b26c798735e500a3c5 (patch)
treee565b20572ce04f668bca249501061e0b16cd23a /tests/dev
parenteb55dd04f26743db3bea673d99cde0d02c27176d (diff)
Use exact match to search testname.
This didn't affect test results.
Diffstat (limited to 'tests/dev')
-rw-r--r--tests/dev/audio/audiotest.c32
-rw-r--r--tests/dev/audio/t_audio.awk4
2 files changed, 29 insertions, 7 deletions
diff --git a/tests/dev/audio/audiotest.c b/tests/dev/audio/audiotest.c
index cca30178451..ab6289b2d3e 100644
--- a/tests/dev/audio/audiotest.c
+++ b/tests/dev/audio/audiotest.c
@@ -1,4 +1,4 @@
-/* $NetBSD: audiotest.c,v 1.7 2020/03/04 14:20:44 isaki Exp $ */
+/* $NetBSD: audiotest.c,v 1.8 2020/03/25 13:07:04 isaki Exp $ */
/*
* Copyright (C) 2019 Tetsuya Isaki. All rights reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: audiotest.c,v 1.7 2020/03/04 14:20:44 isaki Exp $");
+__RCSID("$NetBSD: audiotest.c,v 1.8 2020/03/25 13:07:04 isaki Exp $");
#include <errno.h>
#include <fcntl.h>
@@ -75,6 +75,7 @@ struct testentry {
void usage(void) __dead;
void xp_err(int, int, const char *, ...) __printflike(3, 4) __dead;
void xp_errx(int, int, const char *, ...) __printflike(3, 4) __dead;
+bool match(const char *, const char *);
void xxx_close_wait(void);
int mixer_get_outputs_master(int);
void do_test(int);
@@ -168,6 +169,7 @@ int skipcount;
int unit;
bool use_rump;
bool use_pad;
+bool exact_match;
int padfd;
int maxfd;
pthread_t th;
@@ -186,6 +188,8 @@ usage(void)
fprintf(stderr, "\t-A : make output suitable for ATF\n");
fprintf(stderr, "\t-a : Test all\n");
fprintf(stderr, "\t-d : Increase debug level\n");
+ fprintf(stderr, "\t-e : Use exact match for testnames "
+ "(default is forward match)\n");
fprintf(stderr, "\t-l : List all tests\n");
fprintf(stderr, "\t-p : Open pad\n");
#if !defined(NO_RUMP)
@@ -246,8 +250,9 @@ main(int argc, char *argv[])
cmd = CMD_TEST;
use_pad = false;
padfd = -1;
+ exact_match = false;
- while ((c = getopt(argc, argv, "AadlpRu:")) != -1) {
+ while ((c = getopt(argc, argv, "AadelpRu:")) != -1) {
switch (c) {
case 'A':
opt_atf = true;
@@ -258,6 +263,9 @@ main(int argc, char *argv[])
case 'd':
debug++;
break;
+ case 'e':
+ exact_match = true;
+ break;
case 'l':
cmd = CMD_LIST;
break;
@@ -305,8 +313,7 @@ main(int argc, char *argv[])
found = false;
for (j = 0; j < argc; j++) {
for (i = 0; testtable[i].name != NULL; i++) {
- if (strncmp(argv[j], testtable[i].name,
- strlen(argv[j])) == 0) {
+ if (match(argv[j], testtable[i].name)) {
do_test(i);
found = true;
}
@@ -337,6 +344,21 @@ main(int argc, char *argv[])
return 0;
}
+bool
+match(const char *arg, const char *name)
+{
+ if (exact_match) {
+ /* Exact match */
+ if (strcmp(arg, name) == 0)
+ return true;
+ } else {
+ /* Forward match */
+ if (strncmp(arg, name, strlen(arg)) == 0)
+ return true;
+ }
+ return false;
+}
+
/*
* XXX
* Some hardware drivers (e.g. hdafg(4)) require a little "rest" between
diff --git a/tests/dev/audio/t_audio.awk b/tests/dev/audio/t_audio.awk
index 16a5c601571..e0042b2c5a4 100644
--- a/tests/dev/audio/t_audio.awk
+++ b/tests/dev/audio/t_audio.awk
@@ -1,4 +1,4 @@
-# $NetBSD: t_audio.awk,v 1.1 2020/02/11 07:03:16 isaki Exp $
+# $NetBSD: t_audio.awk,v 1.2 2020/03/25 13:07:04 isaki Exp $
#
# Copyright (C) 2019 Tetsuya Isaki. All rights reserved.
#
@@ -34,7 +34,7 @@ BEGIN {
print "h_audio() {"
print " local testname=$1"
print " local outfile=/tmp/t_audio_$testname.$$"
- print " $(atf_get_srcdir)/audiotest -AR $testname > $outfile"
+ print " $(atf_get_srcdir)/audiotest -ARe $testname > $outfile"
print " local retval=$?"
print " # Discard rump outputs..."
print " outmsg=`cat $outfile | grep -v '^\\['`"