From 55dc79820f60577de3f64fd57bd3a7b1d07cd99a Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 1 Apr 2015 13:07:12 -0700 Subject: [PATCH] build: Add test utility for checking kernel selftest results --- .gitignore | 1 + Makefile.tools | 2 +- tools/check-selftest.c | 71 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 tools/check-selftest.c diff --git a/.gitignore b/.gitignore index 776706277..9fca46c4c 100644 --- a/.gitignore +++ b/.gitignore @@ -82,6 +82,7 @@ tools/gatt-service tools/btgatt-client tools/btgatt-server tools/test-runner +tools/check-selftest tools/mcaptest tools/bneptest test/sap_client.pyc diff --git a/Makefile.tools b/Makefile.tools index 8faf2f4fc..beaac3926 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -226,7 +226,7 @@ noinst_PROGRAMS += tools/bdaddr tools/avinfo tools/avtest \ tools/btiotest tools/bneptest tools/mcaptest \ tools/cltest tools/oobtest tools/seq2bseq \ tools/ibeacon tools/btgatt-client tools/btgatt-server \ - tools/test-runner + tools/test-runner tools/check-selftest tools_bdaddr_SOURCES = tools/bdaddr.c src/oui.h src/oui.c tools_bdaddr_LDADD = lib/libbluetooth-internal.la @UDEV_LIBS@ diff --git a/tools/check-selftest.c b/tools/check-selftest.c new file mode 100644 index 000000000..6006b80ad --- /dev/null +++ b/tools/check-selftest.c @@ -0,0 +1,71 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +static void check_result(const char *name, const char *pathname) +{ + FILE *fp; + int i; + + for (i = 0; i < 50; i++) { + struct stat st; + + if (!stat(pathname, &st)) { + printf("Found %s selftest result\n", name); + break; + } + + usleep(25 * 1000); + } + + fp = fopen(pathname, "re"); + if (fp) { + char result[32], *ptr; + + ptr = fgets(result, sizeof(result), fp); + fclose(fp); + + ptr = strpbrk(result, "\r\n"); + if (ptr) + *ptr = '\0'; + + printf("%s: %s\n", name, result); + } +} + +int main(int argc, char *argv[]) +{ + check_result("ECDH", "/sys/kernel/debug/bluetooth/selftest_ecdh"); + check_result("SMP", "/sys/kernel/debug/bluetooth/selftest_smp"); + + return 0; +} -- 2.47.3