[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1014696: [PATCH] add a DEP-8 autopkgtest



Source: libiberty
Version: 20211102-1
Severity: wishlist
Tags: patch

Hi,

Attached is a patch that adds an autopkgtest to libiberty that exercises
some of its functionality. I agree to keep this up-to-date with new
releases.

Thanks for your consideration

-- System Information:
Debian Release: bookworm/sid
  APT prefers testing-debug
  APT policy: (500, 'testing-debug'), (500, 'testing'), (2, 'unstable-
debug'), (2, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.18.0-2-amd64 (SMP w/2 CPU threads; PREEMPT)
Kernel taint flags: TAINT_USER, TAINT_WARN, TAINT_FIRMWARE_WORKAROUND
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE
not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

diff -wruN a/debian/changelog b/debian/changelog
--- a/debian/changelog	2021-11-02 09:09:37.000000000 -0400
+++ b/debian/changelog	2022-07-10 10:17:53.840907340 -0400
@@ -1,3 +1,10 @@
+libiberty (20211102-2) UNRELEASED; urgency=medium
+
+  [ John Scott ]
+  * Add a DEP-8 test leveraging some functionality of libiberty.
+
+ -- Debian GCC Maintainers <debian-gcc@lists.debian.org>  Sun, 10 Jul 2022 10:17:31 -0400
+
 libiberty (20211102-1) unstable; urgency=medium
 
   * Update to 20210106.
diff -wruN a/debian/copyright b/debian/copyright
--- a/debian/copyright	2017-09-13 06:48:31.000000000 -0400
+++ b/debian/copyright	2022-07-10 10:24:34.296994497 -0400
@@ -135,6 +135,7 @@
 
 Files: debian/*
 Copyright: 2013-2014 Matthias Klose <doko@debian.org>
+ 2022 John Scott <jscott@posteo.net>
 License: GPL-2+
  This package is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
diff -wruN a/debian/tests/control b/debian/tests/control
--- a/debian/tests/control	1969-12-31 19:00:00.000000000 -0500
+++ b/debian/tests/control	2022-07-10 10:23:05.448979031 -0400
@@ -0,0 +1,2 @@
+Test-Command: gcc debian/tests/libiberty.c -liberty -o "$AUTOPKGTEST_TMP"/liberty && "$AUTOPKGTEST_TMP"/liberty
+Depends: gcc, libc-dev, libiberty-dev
diff -wruN a/debian/tests/libiberty.c b/debian/tests/libiberty.c
--- a/debian/tests/libiberty.c	1969-12-31 19:00:00.000000000 -0500
+++ b/debian/tests/libiberty.c	2022-07-10 10:18:06.384910899 -0400
@@ -0,0 +1,68 @@
+#define _POSIX_C_SOURCE 200809L
+#include <errno.h>
+#include <fcntl.h>
+#include <libiberty/libiberty.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+int main(void) {
+	char *s = concat("foo", "bar", "bat", "baz", "cat", "ding", "dong", NULL);
+	if(puts(s) == EOF) {
+		perror("Failed to print string");
+		abort();
+	}
+	free(s);
+
+	if(faccessat(AT_FDCWD, "/proc/self/fd/0", R_OK, AT_EACCESS) != -1) {
+		const int zerofd = open("/proc/self/fd/0", O_RDONLY);
+		if(zerofd == -1) {
+			perror("Failed to open /proc/self/fd/0");
+			abort();
+		}
+		if(!fdmatch(0, zerofd)) {
+			fputs("fds do not match!\n", stderr);
+			abort();
+		}
+		if(close(zerofd) == -1) {
+			perror("Failed to close file descriptor");
+			abort();
+		}
+	}
+
+	if(puts(getpwd()) == EOF) {
+		perror("Failed to print working directory");
+		abort();
+	}
+	if(EINVAL != strtoerrno("EINVAL")) {
+		fputs("strtoerrno failed\n", stderr);
+		abort();
+	}
+	if(strcmp("ERANGE", strerrno(ERANGE))) {
+		fputs("strerrno failed\n", stderr);
+		abort();
+	}
+	if(strcmp("SIGSEGV", strsigno(SIGSEGV))) {
+		fputs("strsigno failed\n", stderr);
+		abort();
+	}
+	if(SIGABRT != strtosigno("SIGABRT")) {
+		fputs("strtosigno failed\n", stderr);
+		abort();
+	}
+
+	s = xasprintf("%d", 0);
+	if(puts(s) == EOF) {
+		perror("Failed to print string");
+		abort();
+	}
+	if(strcmp("0", s)) {
+		fputs("xasprintf gave unexpected results\n", stderr);
+		abort();
+	}
+	free(s);
+
+
+}

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: