[PATCH] hotkey: remove test, it is not really a firmware related test

Colin King colin.king at canonical.com
Fri May 9 15:50:54 UTC 2014


From: Colin Ian King <colin.king at canonical.com>

The hotkey test currently does not work on release releases and
I really don't think anyone is using it.  Since it isn't really
a firmware test and I don't want to maintain it, I think it is
a good opportunity just to remove this interactive test.

Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 .../arg-show-tests-0001/arg-show-tests-0001.log    |   1 -
 .../arg-show-tests-full-0001.log                   |   4 +-
 src/Makefile.am                                    |   1 -
 src/hotkey/hotkey/hotkey.c                         | 268 ---------------------
 4 files changed, 1 insertion(+), 273 deletions(-)
 delete mode 100644 src/hotkey/hotkey/hotkey.c

diff --git a/fwts-test/arg-show-tests-0001/arg-show-tests-0001.log b/fwts-test/arg-show-tests-0001/arg-show-tests-0001.log
index 9833208..85660a8 100644
--- a/fwts-test/arg-show-tests-0001/arg-show-tests-0001.log
+++ b/fwts-test/arg-show-tests-0001/arg-show-tests-0001.log
@@ -46,7 +46,6 @@ Interactive tests:
  ac_adapter      Interactive ac_adapter power test.
  battery         Battery tests.
  brightness      Interactive LCD brightness test.
- hotkey          Hotkey scan code tests.
  lid             Interactive lid button test.
  power_button    Interactive power_button button test.
 
diff --git a/fwts-test/arg-show-tests-full-0001/arg-show-tests-full-0001.log b/fwts-test/arg-show-tests-full-0001/arg-show-tests-full-0001.log
index 074a0f1..1783417 100644
--- a/fwts-test/arg-show-tests-full-0001/arg-show-tests-full-0001.log
+++ b/fwts-test/arg-show-tests-full-0001/arg-show-tests-full-0001.log
@@ -284,8 +284,6 @@ Interactive tests:
   Observe all brightness changes.
   Observe min, max brightness changes.
   Test brightness hotkeys.
- hotkey          (1 test):
-  Hotkey keypress checks.
  lid             (3 tests):
   Test LID buttons report open correctly.
   Test LID buttons on a single open/close.
@@ -367,4 +365,4 @@ UEFI tests:
   Test UEFI RT service set variable interface stress test.
   Test UEFI RT service query variable info interface stress test.
 
-Total of 286 tests
+Total of 285 tests
diff --git a/src/Makefile.am b/src/Makefile.am
index 492eb46..ee87001 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -75,7 +75,6 @@ fwts_SOURCES = main.c 				\
 	cpu/msr/msr.c 				\
 	cpu/microcode/microcode.c 		\
 	dmi/dmicheck/dmicheck.c 		\
-	hotkey/hotkey/hotkey.c 			\
 	hpet/hpet_check/hpet_check.c 		\
 	kernel/klog/klog.c 			\
 	kernel/oops/oops.c 			\
diff --git a/src/hotkey/hotkey/hotkey.c b/src/hotkey/hotkey/hotkey.c
deleted file mode 100644
index d3f8b7d..0000000
--- a/src/hotkey/hotkey/hotkey.c
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Copyright (C) 2010-2014 Canonical
- *
- * 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-#include "fwts.h"
-
-#ifdef FWTS_ARCH_INTEL
-
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <limits.h>
-#include <linux/input.h>
-#include <fcntl.h>
-
-#define AT_KEYBOARD	"AT Translated Set 2 keyboard"
-
-static fwts_list *hotkeys;
-static char *hotkey_dev;
-static char *hotkey_keymap;
-
-static int hotkey_check_key(fwts_framework *fw,
-	struct input_event *ev, fwts_list *hotkeys)
-{
-	static int scancode = 0;
-	fwts_list_link *item;
-	int found = 0;
-
-	if ((ev->code == MSC_SCAN) &&
-	    (ev->type == EV_MSC))
-		scancode = ev->value;
-
-	if ((ev->type == EV_KEY) &&
-	    (ev->value != 0)) {
-		fwts_list_foreach(item, hotkeys) {
-			fwts_keycode *keycode =
-				fwts_list_data(fwts_keycode*, item);
-			if (keycode->scancode == scancode) {
-				fwts_printf(fw, "Scancode: 0x%2.2x Eventcode 0x%3.3x (%s) '%s'\n",
-					scancode, ev->code,
-					keycode->keyname, keycode->keytext);
-				found = 1;
-				break;
-			}
-		}
-		if (!found)
-			fwts_printf(fw, "Scancode: 0x%2.2x Eventcode 0x%3.3x\n",
-				scancode, ev->code);
-	}
-	return FWTS_OK;
-}
-
-
-static int hotkey_test(fwts_framework *fw, char *dev, fwts_list *hotkeys)
-{
-	struct input_event ev;
-	char path[PATH_MAX];
-	int do_test = 1;
-	int fd;
-
-	snprintf(path, sizeof(path), "/dev/%s", dev);
-	if ((fd = open(path, O_RDWR)) < 0) {
-		fwts_log_error(fw, "Cannot open device %s.", path);
-		return FWTS_ERROR;
-	}
-
-	fwts_printf(fw, "Now press all the hotkeys to see if they can be identified.\n");
-	fwts_printf(fw, "Press <ESC> to finish.\n");
-
-	if (ioctl(fd, EVIOCGRAB, (void*)1)) {	/* Get focus */
-		fwts_log_error(fw, "Cannot grab device %s.", path);
-		close(fd);
-		return FWTS_ERROR;
-	}
-
-	while (do_test) {
-		switch (read(fd, &ev, sizeof(ev))) {
-		case -1:
-		case 0:
-			do_test = 0;
-			break;
-		default:
-			if ((ev.type == EV_KEY) &&
-		 	    (ev.code == KEY_ESC) &&
-			    (ev.value == 0))
-				do_test = 0;
-			else
-				hotkey_check_key(fw, &ev, hotkeys);
-			break;
-		}
-	}
-
-	if (ioctl(fd, EVIOCGRAB, (void*)0)) {	/* Release */
-		fwts_log_error(fw, "Cannot un-grab device %s.", path);
-		close(fd);
-		return FWTS_ERROR;
-	}
-	close(fd);
-
-	return FWTS_OK;
-}
-
-static char *hotkey_device(char *path)
-{
-	DIR *scan;
-	struct dirent *scan_entry;
-	char *dev = NULL;
-
-	if ((scan = opendir(path)) == NULL)
-		return NULL;
-
-	while ((scan_entry = readdir(scan)) != NULL) {
-		if (strncmp("event", scan_entry->d_name, 5) == 0) {
-			char filename[PATH_MAX];
-			snprintf(filename, sizeof(filename),
-				"input/%s", scan_entry->d_name);
-			dev = strdup(filename);
-			break;
-		}
-	}
-	closedir(scan);
-
-	return dev;
-}
-
-static char *hotkey_find_keyboard(char *path)
-{
-	DIR *dir;
-	struct dirent *entry;
-	struct stat statbuf;
-	char filename[PATH_MAX];
-	char *dev = NULL;
-	char *data;
-
-	if ((dir = opendir(path)) == NULL)
-		return NULL;
-
-	while ((entry = readdir(dir)) != NULL) {
-		if (strlen(entry->d_name) > 3) {
-			snprintf(filename, sizeof(filename), "%s/%s",
-				path, entry->d_name);
-			if (lstat(filename, &statbuf) == 0) {
-				if (S_ISDIR(statbuf.st_mode)) {
-					if (!S_ISLNK(statbuf.st_mode))
-						if ((dev = hotkey_find_keyboard(filename)) != NULL)
-							break;
-				} else {
-					if ((data = fwts_get(filename)) != NULL) {
-						if (strncmp(data, AT_KEYBOARD, sizeof(AT_KEYBOARD)-1) == 0) {
-							dev = hotkey_device(path);
-							free(data);
-							break;
-						}
-						free(data);
-					}
-				}
-			}
-		}
-	}
-
-	closedir(dir);
-
-	return dev;
-}
-
-static char *hotkey_find_keymap(char *device)
-{
-	fwts_list *output;
-	fwts_list_link *item;
-
-	char buffer[1024];
-	char *keymap = NULL;
-	int status;
-
-	snprintf(buffer, sizeof(buffer), "udevadm test /class/%s 2>&1", device);
-	if (fwts_pipe_exec(buffer, &output, &status) != FWTS_OK)
-		return NULL;
-
-	snprintf(buffer, sizeof(buffer), "keymap %s", device);
-	fwts_list_foreach(item, output) {
-		char *text = fwts_text_list_text(item);
-		if ((text = strstr(text, buffer)) != NULL) {
-			char *ptr;
-			text += strlen(buffer) + 1;
-			if ((ptr = strstr(text, "'")) != NULL)
-				*ptr = '\0';
-			keymap = strdup(text);
-			break;
-		}
-	}
-	fwts_list_free(output, free);
-
-	return keymap;
-}
-
-static int hotkey_init(fwts_framework *fw)
-{
-	if ((hotkey_dev = hotkey_find_keyboard("/sys/devices/platform")) == NULL) {
-		fwts_log_error(fw, "Cannot find keyboard for this machine.");
-		return FWTS_ERROR;
-	}
-	if ((hotkey_keymap = hotkey_find_keymap(hotkey_dev)) == NULL) {
-		fwts_log_error(fw, "Cannot determine keymap for this machine.");
-		return FWTS_ERROR;
-	}
-	if ((hotkeys = fwts_keymap_load(hotkey_keymap)) == NULL) {
-		fwts_log_error(fw, "Cannot load keymap for this machine.");
-		return FWTS_ERROR;
-	}
-
-	return FWTS_OK;
-}
-
-static int hotkey_deinit(fwts_framework *fw)
-{
-	FWTS_UNUSED(fw);
-
-	fwts_keymap_free(hotkeys);
-	free(hotkey_dev);
-	free(hotkey_keymap);
-	return FWTS_OK;
-}
-
-static int hotkey_test1(fwts_framework *fw)
-{
-	fwts_log_info(fw,
-		"This interactive test looks up key presses in the "
-		"keymap and returns any known keymap names for the "
-		"keys.");
-	fwts_log_nl(fw);
-	fwts_log_info(fw, "Using %s keymap and %s input device.", hotkey_keymap, hotkey_dev);
-	hotkey_test(fw, hotkey_dev, hotkeys);
-
-	fwts_infoonly(fw);
-
-	return FWTS_OK;
-}
-
-static fwts_framework_minor_test hotkey_tests[] = {
-	{ hotkey_test1, "Hotkey keypress checks." },
-	{ NULL, NULL }
-};
-
-static fwts_framework_ops hotkey_ops = {
-	.description = "Hotkey scan code tests.",
-	.init        = hotkey_init,
-	.deinit      = hotkey_deinit,
-	.minor_tests = hotkey_tests
-};
-
-FWTS_REGISTER("hotkey", &hotkey_ops, FWTS_TEST_ANYTIME, FWTS_FLAG_INTERACTIVE | FWTS_FLAG_ROOT_PRIV);
-
-#endif
-- 
1.9.1




More information about the fwts-devel mailing list