Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add ATF tests for audio(4).
details: https://anonhg.NetBSD.org/src/rev/03f427377ce2
branches: trunk
changeset: 744718:03f427377ce2
user: isaki <isaki%NetBSD.org@localhost>
date: Tue Feb 11 07:03:16 2020 +0000
description:
Add ATF tests for audio(4).
91 passed test cases
0 failed test cases.
0 expected failed test cases.
62 skipped test cases.
There are many skipped tests, because the test itself supports full-
duplex, half-duplex and uni-directional devices but pad(4) used in ATF
tests is uni-directional device.
diffstat:
distrib/sets/lists/tests/mi | 4 +-
tests/dev/audio/Makefile | 21 +-
tests/dev/audio/audiotest.c | 6434 +++++++++++++++++++++++++++++++++++++++++++
tests/dev/audio/t_audio.awk | 76 +
4 files changed, 6530 insertions(+), 5 deletions(-)
diffs (truncated from 6581 to 300 lines):
diff -r 8e92d7704df4 -r 03f427377ce2 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Tue Feb 11 06:33:51 2020 +0000
+++ b/distrib/sets/lists/tests/mi Tue Feb 11 07:03:16 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.829 2020/02/11 03:15:10 riastradh Exp $
+# $NetBSD: mi,v 1.830 2020/02/11 07:03:16 isaki Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -1391,7 +1391,9 @@
./usr/tests/dev/audio tests-fs-tests compattestfile,atf
./usr/tests/dev/audio/Atffile tests-fs-tests atf,rump
./usr/tests/dev/audio/Kyuafile tests-fs-tests atf,rump,kyua
+./usr/tests/dev/audio/audiotest tests-fs-tests atf,rump
./usr/tests/dev/audio/h_pad tests-fs-tests atf,rump
+./usr/tests/dev/audio/t_audio tests-fs-tests atf,rump
./usr/tests/dev/audio/t_pad tests-fs-tests atf,rump
./usr/tests/dev/audio/t_pad_output.bz2.uue tests-obsolete obsolete
./usr/tests/dev/cgd tests-fs-tests compattestfile,atf
diff -r 8e92d7704df4 -r 03f427377ce2 tests/dev/audio/Makefile
--- a/tests/dev/audio/Makefile Tue Feb 11 06:33:51 2020 +0000
+++ b/tests/dev/audio/Makefile Tue Feb 11 07:03:16 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.6 2019/06/20 12:14:46 isaki Exp $
+# $NetBSD: Makefile,v 1.7 2020/02/11 07:03:16 isaki Exp $
#
.include <bsd.own.mk>
@@ -6,13 +6,20 @@
TESTSDIR= ${TESTSBASE}/dev/audio
FILESDIR= ${TESTSDIR}
-TESTS_SH= t_pad
+PROGS+= audiotest
+PROGS+= h_pad
+
+SRCS.audiotest= audiotest.c
+LDADD.audiotest+= -lutil
+
+SRCS.h_pad= h_pad.c
+
+TESTS_SH+= t_audio
+TESTS_SH+= t_pad
BINDIR= ${TESTSDIR}
MKMAN=no
-PROGS= h_pad
-
CPPFLAGS+= -D_KERNTYPES
LDADD+= -lrumpdev_pad -lrumpdev_audio -lrumpdev -lrumpvfs
LDADD+= -lrump
@@ -23,4 +30,10 @@
WARNS= 4
NOMAN=
+CLEANFILES+= t_audio.sh
+
+t_audio.sh: t_audio.awk audiotest.c
+ ${_MKTARGET_CREATE}
+ ${TOOL_AWK} -f ${.ALLSRC} > ${.TARGET}
+
.include <bsd.test.mk>
diff -r 8e92d7704df4 -r 03f427377ce2 tests/dev/audio/audiotest.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/dev/audio/audiotest.c Tue Feb 11 07:03:16 2020 +0000
@@ -0,0 +1,6434 @@
+/* $NetBSD: audiotest.c,v 1.1 2020/02/11 07:03:16 isaki Exp $ */
+
+/*
+ * Copyright (C) 2019 Tetsuya Isaki. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: audiotest.c,v 1.1 2020/02/11 07:03:16 isaki Exp $");
+
+#include <errno.h>
+#include <fcntl.h>
+#define __STDC_FORMAT_MACROS /* for PRIx64 */
+#include <inttypes.h>
+#include <pthread.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <util.h>
+#include <sys/audioio.h>
+#include <sys/event.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/poll.h>
+#include <sys/sysctl.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#if !defined(NO_RUMP)
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+#endif
+
+#if !defined(AUDIO_ENCODING_SLINEAR_NE)
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define AUDIO_ENCODING_SLINEAR_NE AUDIO_ENCODING_SLINEAR_LE
+#define AUDIO_ENCODING_ULINEAR_NE AUDIO_ENCODING_ULINEAR_LE
+#define AUDIO_ENCODING_SLINEAR_OE AUDIO_ENCODING_SLINEAR_BE
+#define AUDIO_ENCODING_ULINEAR_OE AUDIO_ENCODING_ULINEAR_BE
+#else
+#define AUDIO_ENCODING_SLINEAR_NE AUDIO_ENCODING_SLINEAR_BE
+#define AUDIO_ENCODING_ULINEAR_NE AUDIO_ENCODING_ULINEAR_BE
+#define AUDIO_ENCODING_SLINEAR_OE AUDIO_ENCODING_SLINEAR_LE
+#define AUDIO_ENCODING_ULINEAR_OE AUDIO_ENCODING_ULINEAR_LE
+#endif
+#endif
+
+struct testentry {
+ const char *name;
+ void (*func)(void);
+};
+
+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;
+void xxx_close_wait(void);
+int mixer_get_outputs_master(int);
+void do_test(int);
+int rump_or_open(const char *, int);
+int rump_or_write(int, const void *, size_t);
+int rump_or_read(int, void *, size_t);
+int rump_or_ioctl(int, u_long, void *);
+int rump_or_close(int);
+int rump_or_fcntl(int, int, ...);
+int rump_or_poll(struct pollfd *, nfds_t, int);
+int rump_or_kqueue(void);
+int rump_or_kevent(int, const struct kevent *, size_t,
+ struct kevent *, size_t, const struct timespec *);
+int hw_canplay(void);
+int hw_canrec(void);
+int hw_bidir(void);
+int hw_fulldup(void);
+void init(int);
+void *consumer_thread(void *);
+void cleanup_audiofd(void);
+void TEST(const char *, ...) __printflike(1, 2);
+bool xp_fail(int, const char *, ...) __printflike(2, 3);
+void xp_skip(int, const char *, ...) __printflike(2, 3);
+bool xp_eq(int, int, int, const char *);
+bool xp_eq_str(int, const char *, const char *, const char *);
+bool xp_ne(int, int, int, const char *);
+bool xp_if(int, bool, const char *);
+bool xp_sys_eq(int, int, int, const char *);
+bool xp_sys_ok(int, int, const char *);
+bool xp_sys_ng(int, int, int, const char *);
+bool xp_sys_ptr(int, int, void *, const char *);
+bool xp_buffsize(int, bool, int, const char *);
+int debug_open(int, const char *, int);
+int debug_write(int, int, const void *, size_t);
+int debug_read(int, int, void *, size_t);
+int debug_ioctl(int, int, u_long, const char *, void *, const char *, ...)
+ __printflike(6, 7);
+int debug_fcntl(int, int, int, const char *, ...) __printflike(4, 5);
+int debug_close(int, int);
+void *debug_mmap(int, void *, size_t, int, int, int, off_t);
+int debug_munmap(int, void *, int);
+const char *event_tostr(int);
+int debug_poll(int, struct pollfd *, int, int);
+int debug_kqueue(int);
+int debug_kevent_set(int, int, const struct kevent *, size_t);
+int debug_kevent_poll(int, int, struct kevent *, size_t,
+ const struct timespec *);
+void debug_kev(int, const char *, const struct kevent *);
+uid_t debug_getuid(int);
+int debug_seteuid(int, uid_t);
+int debug_sysctlbyname(int, const char *, void *, size_t *, const void *,
+ size_t);
+
+int openable_mode(void);
+int mode2aumode(int);
+int mode2play(int);
+int mode2rec(int);
+void reset_after_mmap(void);
+
+/* from audio.c */
+static const char *encoding_names[] __unused = {
+ "none",
+ AudioEmulaw,
+ AudioEalaw,
+ "pcm16",
+ "pcm8",
+ AudioEadpcm,
+ AudioEslinear_le,
+ AudioEslinear_be,
+ AudioEulinear_le,
+ AudioEulinear_be,
+ AudioEslinear,
+ AudioEulinear,
+ AudioEmpeg_l1_stream,
+ AudioEmpeg_l1_packets,
+ AudioEmpeg_l1_system,
+ AudioEmpeg_l2_stream,
+ AudioEmpeg_l2_packets,
+ AudioEmpeg_l2_system,
+ AudioEac3,
+};
+
+int debug;
+int props;
+int hwfull;
+int netbsd;
+bool opt_atf;
+char testname[64];
+int testcount;
+int failcount;
+int skipcount;
+int unit;
+bool use_rump;
+bool use_pad;
+int padfd;
+int maxfd;
+pthread_t th;
+char devicename[16]; /* "audioN" */
+char devaudio[16]; /* "/dev/audioN" */
+char devsound[16]; /* "/dev/soundN" */
+char devaudioctl[16]; /* "/dev/audioctlN" */
+char devmixer[16]; /* "/dev/mixerN" */
+extern struct testentry testtable[];
+
+void
+usage(void)
+{
+ fprintf(stderr, "usage:\t%s [<options>] [<testname>...]\n",
+ getprogname());
+ 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-l : List all tests\n");
+ fprintf(stderr, "\t-p : Open pad\n");
+#if !defined(NO_RUMP)
+ fprintf(stderr, "\t-R : Use rump (implies -p)\n");
+#endif
+ fprintf(stderr, "\t-u <unit> : Use audio<unit> (default:0)\n");
+ exit(1);
+}
+
+/* Customized err(3) */
+void
+xp_err(int code, int line, const char *fmt, ...)
+{
+ va_list ap;
+ int backup_errno;
+
+ backup_errno = errno;
+ printf("%s %d: ", (opt_atf ? "Line" : " ERROR:"), line);
+ va_start(ap, fmt);
+ vprintf(fmt, ap);
+ va_end(ap);
+ printf(": %s\n", strerror(backup_errno));
+
+ exit(code);
+}
+
+/* Customized errx(3) */
+void
+xp_errx(int code, int line, const char *fmt, ...)
+{
+ va_list ap;
+
+ printf("%s %d: ", (opt_atf ? "Line" : " ERROR:"), line);
+ va_start(ap, fmt);
+ vprintf(fmt, ap);
+ va_end(ap);
+ printf("\n");
+
+ exit(code);
+}
+
+int
+main(int argc, char *argv[])
+{
Home |
Main Index |
Thread Index |
Old Index