Blob: check-selftest.c
Blob id: 9a6f22d57b3c1bd99cd421ed2ea93882a0e29d1a
Size: 1014 B
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | // SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. * * */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #define _GNU_SOURCE #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> 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; } |