Commit 71268f32 authored by TBK's avatar TBK Committed by Leo

testing/hidrd: modernize

- Clarify license
- Enable check
- Fix for GCC10
parent 79ec9961
......@@ -5,14 +5,15 @@ pkgrel=0
pkgdesc="HID report descriptor I/O library and conversion tool"
url="https://github.com/DIGImend/hidrd"
arch="all"
license="GPL-2.0"
depends=""
license="GPL-2.0-or-later"
makedepends="musl-obstack-dev m4"
install=""
checkdepends="bash coreutils linux-headers"
subpackages="$pkgname-dev"
source="https://github.com/DIGImend/hidrd/releases/download/$pkgver/hidrd-$pkgver.tar.gz
musl-fix-headers.patch"
builddir="$srcdir/hidrd-$pkgver"
musl-fix-headers.patch
b622af32bd0e72cf0c6dffff6c9c8852f065051e.patch
fix-check.patch
"
prepare() {
default_prepare
......@@ -20,7 +21,6 @@ prepare() {
}
build() {
cd "$builddir"
LIBS=-lobstack \
./configure \
--build=$CBUILD \
......@@ -32,10 +32,15 @@ build() {
make
}
check() {
make check
}
package() {
cd "$builddir"
make DESTDIR="$pkgdir" install
}
sha512sums="b2121904f7327766b17ade631d6862cea6c0010cee060620150480f70ed0fb00cebf06cd2c6623ab509e1579abe2a835920d8c5290c21bca4143b15c6a814e22 hidrd-0.2.0.tar.gz
43651cd05b01867eeba370786c6db06b6d7d31713607ee34c1529377463dcf12c8af4efbcbe9ee27018deef030e63ad324a364d2701fde5c369edd7206427ee1 musl-fix-headers.patch"
43651cd05b01867eeba370786c6db06b6d7d31713607ee34c1529377463dcf12c8af4efbcbe9ee27018deef030e63ad324a364d2701fde5c369edd7206427ee1 musl-fix-headers.patch
c465828217427463f3e79d108a998a3afbf976de51a918732832271fc8a576a4f9efe84c691f078a440e414b8065d8d4f40a607f03c06db1872460a676325827 b622af32bd0e72cf0c6dffff6c9c8852f065051e.patch
4e4057ce5fd1ba79a3c120927351629487a5b8466fad5be359be46046b075bbfdc92b375de32d9fa0a0863df7701bb0d2f56aff96e421190c2f024d2a4d6e161 fix-check.patch"
From 40882553e8210dae0736c0bcb9d5d39d50ccdcfe Mon Sep 17 00:00:00 2001
From: Klee Dienes <klee@mit.edu>
Date: Sat, 19 Mar 2016 07:21:52 -0400
Subject: [PATCH] Add 'extern' keyword to hidrd_natv_sink.
Otherwise the 'const' keyword gives it wonky linkage. With this change,
hidrd_natv_sink matches hidrd_natv_src.
---
include/hidrd/fmt/natv/snk.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/hidrd/fmt/natv/snk.h b/include/hidrd/fmt/natv/snk.h
index 5d043bd..4b367ef 100644
--- a/include/hidrd/fmt/natv/snk.h
+++ b/include/hidrd/fmt/natv/snk.h
@@ -34,7 +34,7 @@ extern "C" {
#endif
/** Native sink type */
-const hidrd_snk_type hidrd_natv_snk;
+extern const hidrd_snk_type hidrd_natv_snk;
/** Native sink error code */
typedef enum hidrd_natv_snk_err {
From b622af32bd0e72cf0c6dffff6c9c8852f065051e Mon Sep 17 00:00:00 2001
From: Nikolai Kondrashov <Nikolai.Kondrashov@redhat.com>
Date: Sat, 18 Jun 2016 19:20:31 +0300
Subject: [PATCH] Add missing extern to declarations
Add "extern" to several missing declarations throughout the code, in
particular to avoid uninitialized copies of variables. This fixes an
assertion failure upon "hidrd-convert -h" invocation.
---
include/hidrd/fmt/code/snk.h | 2 +-
include/hidrd/fmt/spec/snk.h | 2 +-
include/hidrd/usage/id_desc_list.h.m4 | 4 ++--
include/hidrd/usage/page_desc_list.h.m4 | 4 ++--
5 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/include/hidrd/fmt/code/snk.h b/include/hidrd/fmt/code/snk.h
index e595f64..4d826fe 100644
--- a/include/hidrd/fmt/code/snk.h
+++ b/include/hidrd/fmt/code/snk.h
@@ -34,7 +34,7 @@ extern "C" {
#endif
/** Source code sink type */
-const hidrd_snk_type hidrd_code_snk;
+extern const hidrd_snk_type hidrd_code_snk;
/** Source code sink instance */
typedef struct hidrd_code_snk_inst {
diff --git a/include/hidrd/fmt/spec/snk.h b/include/hidrd/fmt/spec/snk.h
index 56974f4..ca073d4 100644
--- a/include/hidrd/fmt/spec/snk.h
+++ b/include/hidrd/fmt/spec/snk.h
@@ -51,7 +51,7 @@ extern bool hidrd_spec_snk_flush(hidrd_snk *snk);
extern void hidrd_spec_snk_clnp(hidrd_snk *snk);
/** Specification example sink type */
-const hidrd_snk_type hidrd_spec_snk;
+extern const hidrd_snk_type hidrd_spec_snk;
/** Specification example sink item state table */
typedef struct hidrd_spec_snk_state hidrd_spec_snk_state;
diff --git a/include/hidrd/usage/id_desc_list.h.m4 b/include/hidrd/usage/id_desc_list.h.m4
index bc57082..1cde027 100644
--- a/include/hidrd/usage/id_desc_list.h.m4
+++ b/include/hidrd/usage/id_desc_list.h.m4
@@ -68,13 +68,13 @@ extern "C" {
extern bool hidrd_usage_id_desc_list_valid(const hidrd_usage_id_desc *list,
size_t num);
-const hidrd_usage_id_desc *hidrd_usage_id_desc_list_lkp_by_value(
+extern const hidrd_usage_id_desc *hidrd_usage_id_desc_list_lkp_by_value(
const hidrd_usage_id_desc *list,
size_t num,
hidrd_usage_id value);
#ifdef HIDRD_WITH_TOKENS
-const hidrd_usage_id_desc *hidrd_usage_id_desc_list_lkp_by_token(
+extern const hidrd_usage_id_desc *hidrd_usage_id_desc_list_lkp_by_token(
const hidrd_usage_id_desc *list,
size_t num,
const char *token);
diff --git a/include/hidrd/usage/page_desc_list.h.m4 b/include/hidrd/usage/page_desc_list.h.m4
index 7331d56..f83ebd1 100644
--- a/include/hidrd/usage/page_desc_list.h.m4
+++ b/include/hidrd/usage/page_desc_list.h.m4
@@ -80,7 +80,7 @@ popdef(`page_num')dnl
*
* @return Page description or NULL, if not found.
*/
-const hidrd_usage_page_desc *hidrd_usage_page_desc_list_lkp_by_value(
+extern const hidrd_usage_page_desc *hidrd_usage_page_desc_list_lkp_by_value(
hidrd_usage_page value);
#ifdef HIDRD_WITH_TOKENS
@@ -91,7 +91,7 @@ const hidrd_usage_page_desc *hidrd_usage_page_desc_list_lkp_by_value(
*
* @return Page description or NULL, if not found.
*/
-const hidrd_usage_page_desc *hidrd_usage_page_desc_list_lkp_by_token(
+extern const hidrd_usage_page_desc *hidrd_usage_page_desc_list_lkp_by_token(
const char *token);
#endif /* HIDRD_WITH_TOKENS */
musl libc does currently not have an equivalent of GNU Libc's error.h
The following is a mix of a workaround from aufs (https://sourceforge.net/p/aufs/aufs-util/ci/aufs4.14/tree/extlib/non-glibc/)
and the stranded error.{h,c} implementation https://www.openwall.com/lists/musl/2019/08/06/21
--- a/lib/fmt/xml_test.c
+++ b/lib/fmt/xml_test.c
@@ -27,7 +27,11 @@
#include <stdint.h>
#include <string.h>
#include <errno.h>
+#ifdef __GNU_LIBRARY__
#include <error.h>
+#else
+#include "hidrd/util/error_at_line.h"
+#endif
#include <stdio.h>
#include "hidrd/fmt/xml.h"
--- a/lib/item/any_test.c
+++ b/lib/item/any_test.c
@@ -29,7 +29,11 @@
#include <stdint.h>
#include <string.h>
#include <errno.h>
+#ifdef __GNU_LIBRARY__
#include <error.h>
+#else
+#include "hidrd/util/error_at_line.h"
+#endif
#include <stdio.h>
#include "hidrd/item.h"
--- a/lib/opt/test.c
+++ b/lib/opt/test.c
@@ -28,7 +28,11 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#ifdef __GNU_LIBRARY__
#include <error.h>
+#else
+#include "hidrd/util/error_at_line.h"
+#endif
#include <stdio.h>
#include "hidrd/opt/spec_list.h"
#include "hidrd/opt/list.h"
--- a/lib/util/num_test.c
+++ b/lib/util/num_test.c
@@ -25,7 +25,11 @@
*/
#include <assert.h>
+#ifdef __GNU_LIBRARY__
#include <error.h>
+#else
+#include "hidrd/util/error_at_line.h"
+#endif
#include <stdlib.h>
#include <string.h>
#include "hidrd/util/num.h"
--- a/lib/util/ttbl_test.c
+++ b/lib/util/ttbl_test.c
@@ -26,7 +26,11 @@
#include <assert.h>
#include <errno.h>
+#ifdef __GNU_LIBRARY__
#include <error.h>
+#else
+#include "hidrd/util/error_at_line.h"
+#endif
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
Only in src/hidrd-0.2.0/lib/: error
--- a/lib/util/Makefile.am
+++ b/lib/util/Makefile.am
@@ -39,10 +39,10 @@
bin_PROGRAMS =
check_PROGRAMS = hidrd_num_test hidrd_ttbl_test
-hidrd_num_test_SOURCES = num_test.c
+hidrd_num_test_SOURCES = num_test.c error_at_line.c
hidrd_num_test_LDADD = $(lib_LTLIBRARIES)
-hidrd_ttbl_test_SOURCES = ttbl_test.c
+hidrd_ttbl_test_SOURCES = ttbl_test.c error_at_line.c
hidrd_ttbl_test_LDADD = $(lib_LTLIBRARIES)
TESTS = hidrd_num_test hidrd_ttbl_test
--- a/lib/util/Makefile.in
+++ b/lib/util/Makefile.in
@@ -102,10 +102,12 @@
am__EXEEXT_1 = hidrd_num_test$(EXEEXT) hidrd_ttbl_test$(EXEEXT)
@ENABLE_TESTS_INSTALL_TRUE@am__EXEEXT_2 = $(am__EXEEXT_1)
PROGRAMS = $(bin_PROGRAMS)
-am_hidrd_num_test_OBJECTS = num_test.$(OBJEXT)
+am_hidrd_num_test_OBJECTS = num_test.$(OBJEXT) \
+ error_at_line.$(OBJEXT)
hidrd_num_test_OBJECTS = $(am_hidrd_num_test_OBJECTS)
hidrd_num_test_DEPENDENCIES = $(lib_LTLIBRARIES)
-am_hidrd_ttbl_test_OBJECTS = ttbl_test.$(OBJEXT)
+am_hidrd_ttbl_test_OBJECTS = ttbl_test.$(OBJEXT) \
+ error_at_line.$(OBJEXT)
hidrd_ttbl_test_OBJECTS = $(am_hidrd_ttbl_test_OBJECTS)
hidrd_ttbl_test_DEPENDENCIES = $(lib_LTLIBRARIES)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
@@ -247,9 +249,9 @@
lib_LTLIBRARIES = libhidrd_util.la
libhidrd_util_la_SOURCES = bool.c buf.c char.c dec.c fd.c fmt.c hex.c \
num.c str.c ttbl.c unit.c $(am__append_1)
-hidrd_num_test_SOURCES = num_test.c
+hidrd_num_test_SOURCES = num_test.c error_at_line.c
hidrd_num_test_LDADD = $(lib_LTLIBRARIES)
-hidrd_ttbl_test_SOURCES = ttbl_test.c
+hidrd_ttbl_test_SOURCES = ttbl_test.c error_at_line.c
hidrd_ttbl_test_LDADD = $(lib_LTLIBRARIES)
all: all-am
@@ -387,6 +389,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/buf.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/char.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dec.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error_at_line.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fd.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fmt.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hex.Plo@am__quote@
--- /dev/null
+++ b/lib/util/error_at_line.c
@@ -0,0 +1,69 @@
+#include "hidrd/util/error_at_line.h"
+#include <errno.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+void (*error_print_progname) (void) = 0;
+unsigned int error_message_count = 0;
+int error_one_per_line = 0;
+
+static unsigned int saved_linenum = 0;
+static const char *saved_file = 0;
+
+static void errorv(int status, int errnum, const char *file, unsigned int linenum, const char *fmt, va_list ap)
+{
+ ++error_message_count;
+
+ fflush(stdout);
+ flockfile(stderr);
+
+ if (error_print_progname)
+ error_print_progname();
+ else {
+ fprintf(stderr, "%s:", program_invocation_name);
+ if (!file)
+ fputc(' ', stderr);
+ }
+
+ if (file)
+ fprintf(stderr, "%s:%u: ", file, linenum);
+
+ vfprintf(stderr, fmt, ap);
+ if (errnum)
+ fprintf(stderr, ": %s", strerror(errnum));
+ fputc('\n', stderr);
+
+ funlockfile(stderr);
+
+ if (status)
+ exit(status);
+}
+
+void error(int status, int errnum, const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ errorv(status, errnum, NULL, 0, fmt, ap);
+ va_end(ap);
+}
+
+void error_at_line(int status, int errnum, const char *file, unsigned int linenum, const char *fmt, ...)
+{
+ if (error_one_per_line) {
+ if(saved_linenum == linenum && file != NULL &&
+ saved_file != NULL && !strcmp(file, saved_file))
+ return;
+ saved_linenum = linenum;
+ // Assuming that the lifetime of the passed in file name extends
+ // until the next call is rather questionable, but appears to be
+ // the expected semantics.
+ saved_file = file;
+ }
+
+ va_list ap;
+ va_start(ap, fmt);
+ errorv(status, errnum, file, linenum, fmt, ap);
+ va_end(ap);
+}
--- /dev/null
+++ b/include/hidrd/util/error_at_line.h
@@ -0,0 +1,21 @@
+#ifndef _ERROR_H
+#define _ERROR_H
+
+#include <features.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern void (*error_print_progname) (void);
+extern unsigned int error_message_count;
+extern int error_one_per_line;
+
+void error(int, int, const char *, ...);
+void error_at_line(int, int, const char *, unsigned int, const char *, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- a/lib/opt/Makefile.am
+++ b/lib/opt/Makefile.am
@@ -36,7 +36,7 @@
TESTS = hidrd_opt_test
-hidrd_opt_test_SOURCES = test.c
+hidrd_opt_test_SOURCES = test.c ../util/error_at_line.c
hidrd_opt_test_LDADD = $(lib_LTLIBRARIES)
bin_PROGRAMS =
--- a/lib/opt/Makefile.in
+++ b/lib/opt/Makefile.in
@@ -98,7 +98,8 @@
am__EXEEXT_1 = hidrd_opt_test$(EXEEXT)
@ENABLE_TESTS_INSTALL_TRUE@am__EXEEXT_2 = $(am__EXEEXT_1)
PROGRAMS = $(bin_PROGRAMS)
-am_hidrd_opt_test_OBJECTS = test.$(OBJEXT)
+am_hidrd_opt_test_OBJECTS = test.$(OBJEXT) \
+ error_at_line.$(OBJEXT)
hidrd_opt_test_OBJECTS = $(am_hidrd_opt_test_OBJECTS)
hidrd_opt_test_DEPENDENCIES = $(lib_LTLIBRARIES)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
@@ -251,7 +252,7 @@
libhidrd_opt_la_LIBADD = \
../util/libhidrd_util.la
-hidrd_opt_test_SOURCES = test.c
+hidrd_opt_test_SOURCES = test.c ../util/error_at_line.c
hidrd_opt_test_LDADD = $(lib_LTLIBRARIES)
all: all-am
@@ -382,6 +383,7 @@
distclean-compile:
-rm -f *.tab.c
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error_at_line.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inst.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/name_tkn.Plo@am__quote@
@@ -415,6 +417,20 @@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+error_at_line.o: ../util/error_at_line.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT error_at_line.o -MD -MP -MF $(DEPDIR)/error_at_line.Tpo -c -o error_at_line.o `test -f '../util/error_at_line.c' || echo '$(srcdir)/'`../util/error_at_line.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/error_at_line.Tpo $(DEPDIR)/error_at_line.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../util/error_at_line.c' object='error_at_line.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o error_at_line.o `test -f '../util/error_at_line.c' || echo '$(srcdir)/'`../util/error_at_line.c
+
+error_at_line.obj: ../util/error_at_line.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT error_at_line.obj -MD -MP -MF $(DEPDIR)/error_at_line.Tpo -c -o error_at_line.obj `if test -f '../util/error_at_line.c'; then $(CYGPATH_W) '../util/error_at_line.c'; else $(CYGPATH_W) '$(srcdir)/../util/error_at_line.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/error_at_line.Tpo $(DEPDIR)/error_at_line.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../util/error_at_line.c' object='error_at_line.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o error_at_line.obj `if test -f '../util/error_at_line.c'; then $(CYGPATH_W) '../util/error_at_line.c'; else $(CYGPATH_W) '$(srcdir)/../util/error_at_line.c'; fi`
+
mostlyclean-libtool:
-rm -f *.lo
From f876ac085a86cc932c7d3093a7d007c78bff4751 Mon Sep 17 00:00:00 2001
From: Jason Gerecke <killertofu@gmail.com>
Date: Tue, 26 Apr 2016 13:28:04 -0700
Subject: [PATCH] Replace use of 'tempfile' with 'mktemp' in tests
The 'tempfile' command has been deprecated in Debian for many years
at this point and may not even be available on modern systems. Use
'mktemp' as the recommended replacement.
---
lib/fmt/hidrd_read_test | 6 +++---
lib/fmt/hidrd_write_test | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/fmt/hidrd_read_test b/lib/fmt/hidrd_read_test
index 8ae1350..6b30f6b 100755
--- a/lib/fmt/hidrd_read_test
+++ b/lib/fmt/hidrd_read_test
@@ -39,9 +39,9 @@ function run ()
local input="$1"; shift
local output="$1"; shift
local output_basename="`basename \"$output\"`"
- local test_output="`tempfile -s\"_$output_basename.test\"`"
- local txt_output="`tempfile -s\"_$output_basename.txt\"`"
- local test_txt_output="`tempfile -s\"_$output_basename.txt.test\"`"
+ local test_output="`mktemp --suffix=\"_$output_basename.test\"`"
+ local txt_output="`mktemp --suffix=\"_$output_basename.txt\"`"
+ local test_txt_output="`mktemp --suffix=\"_$output_basename.txt.test\"`"
local status
echo "Checking \"$format\" reading from \"$input\"" \
diff --git a/lib/fmt/hidrd_write_test b/lib/fmt/hidrd_write_test
index 3cfb0aa..73dddd8 100755
--- a/lib/fmt/hidrd_write_test
+++ b/lib/fmt/hidrd_write_test
@@ -34,7 +34,7 @@ function run ()
local input="$1"; shift
local output="$1"; shift
local output_basename="`basename \"$output\"`"
- local test_output="`tempfile -s\"_$output_basename.test\"`"
+ local test_output="`mktemp --suffix=\"_$output_basename.test\"`"
local status
echo "Checking \"$format\" writing of \"$input\"" \
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment