Skip to contentSkip to conversation

+ selftests-add-support-files-for-powerpc-tests.patch added to -mm tree

PATCH [email protected] 1 participant 1 message Aug 6, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Subject: + selftests-add-support-files-for-powerpc-tests.patch added to -mm tree
To: [email protected],[email protected],[email protected],[email protected],[email protected]
From: [email protected]
Date: Tue, 06 Aug 2013 14:47:35 -0700

The patch titled
Subject: selftests: add support files for powerpc tests
has been added to the -mm tree. Its filename is
selftests-add-support-files-for-powerpc-tests.patch

This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/selftests-add-support-files-for-powerpc-tests.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/selftests-add-support-files-for-powerpc-tests.patch

Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated there every 3-4 working days

------------------------------------------------------
From: Michael Ellerman <[email protected]>
Subject: selftests: add support files for powerpc tests

Add support code used by upcoming powerpc tests.

Cc Anton Blanchard <[email protected]>
Cc Jeremy Kerr <[email protected]>
Cc Michael Neuling <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>

---

 tools/testing/selftests/powerpc/harness.c |  105 ++++++++++++++++++++
 tools/testing/selftests/powerpc/subunit.h |   47 ++++++++
 tools/testing/selftests/powerpc/utils.h   |   34 ++++++
 3 files changed, 186 insertions(+)
tools/testing/selftests/powerpc/harness.c new file +105 -0
diff -puN /dev/null tools/testing/selftests/powerpc/harness.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2013, Michael Ellerman, IBM Corp.
+ * Licensed under GPLv2.
+ */
+
+#include <errno.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#include "subunit.h"
+#include "utils.h"
+
+#define TIMEOUT		120
+#define KILL_TIMEOUT	5
+
+
+int run_test(int (test_function)(void), char *name)
+{
+	bool terminated;
+	int rc, status;
+	pid_t pid;
+
+	/* Make sure output is flushed before forking */
+	fflush(stdout);
+
+	pid = fork();
+	if (pid == 0) {
+		exit(test_function());
+	} else if (pid == -1) {
+		perror("fork");
+		return 1;
+	}
+
+	/* Wake us up in timeout seconds */
+	alarm(TIMEOUT);
+	terminated = false;
+
+wait:
+	rc = waitpid(pid, &status, 0);
+	if (rc == -1) {
+		if (errno != EINTR) {
+			printf("unknown error from waitpid\n");
+			return 1;
+		}
+
+		if (terminated) {
+			printf("!! force killing %s\n", name);
+			kill(pid, SIGKILL);
+			return 1;
+		} else {
+			printf("!! killing %s\n", name);
+			kill(pid, SIGTERM);
+			terminated = true;
+			alarm(KILL_TIMEOUT);
+			goto wait;
+		}
+	}
+
+	if (WIFEXITED(status))
+		status = WEXITSTATUS(status);
+	else {
+		if (WIFSIGNALED(status))
+			printf("!! child died by signal %d\n", WTERMSIG(status));
+		else
+			printf("!! child died by unknown cause\n");
+
+		status = 1; /* Signal or other */
+	}
+
+	return status;
+}
+
+static void alarm_handler(int signum)
+{
+	/* Jut wake us up from waitpid */
+}
+
+static struct sigaction alarm_action = {
+	.sa_handler = alarm_handler,
+};
+
+int test_harness(int (test_function)(void), char *name)
+{
+	int rc;
+
+	test_start(name);
+	test_set_git_version(GIT_VERSION);
+
+	if (sigaction(SIGALRM, &alarm_action, NULL)) {
+		perror("sigaction");
+		test_error(name);
+		return 1;
+	}
+
+	rc = run_test(test_function, name);
+
+	test_finish(name, rc);
+
+	return rc;
+}
tools/testing/selftests/powerpc/subunit.h new file +47 -0

47 lines not on this page · raw message

tools/testing/selftests/powerpc/utils.h new file +34 -0
diff -puN /dev/null tools/testing/selftests/powerpc/utils.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2013, Michael Ellerman, IBM Corp.
+ * Licensed under GPLv2.
+ */
+
+#ifndef _SELFTESTS_POWERPC_UTILS_H
+#define _SELFTESTS_POWERPC_UTILS_H
+
+#include <stdint.h>
+#include <stdbool.h>
+
+/* Avoid headaches with PRI?64 - just use %ll? always */
+typedef unsigned long long u64;
+typedef   signed long long s64;
+
+/* Just for familiarity */
+typedef uint32_t u32;
+typedef uint8_t u8;
+
+
+int test_harness(int (test_function)(void), char *name);
+
+
+/* Yes, this is evil */
+#define FAIL_IF(x)						\
+do {								\
+	if ((x)) {						\
+		fprintf(stderr,					\
+		"[FAIL] Test FAILED on line %d\n", __LINE__);	\
+		return 1;					\
+	}							\
+} while (0)
+
+#endif /* _SELFTESTS_POWERPC_UTILS_H */

_

Patches currently in -mm which might be from [email protected] are

selftests-add-infrastructure-for-powerpc-selftests.patch selftests-add-support-files-for-powerpc-tests.patch selftests-add-test-of-pmu-instruction-counting-on-powerpc.patch linux-next.patch