*/
#include <stdlib.h>
-#include <string.h>
#include <stdio.h>
#include <stddef.h>
#include <unistd.h>
#include <errno.h>
-#include <ctype.h>
-#include <fcntl.h>
#include <signal.h>
#include <getopt.h>
#include <sys/signalfd.h>
#include "udev.h"
#include "udev-util.h"
+static void help(void) {
+
+ printf("%s test OPTIONS <syspath>\n\n"
+ "Test an event run.\n"
+ " -h --help Show this help\n"
+ " --version Show package version\n"
+ " -a --action=ACTION Set action string\n"
+ " -N --resolve-names=early|late|never When to resolve names\n"
+ , program_invocation_short_name);
+}
+
static int adm_test(struct udev *udev, int argc, char *argv[]) {
int resolve_names = 1;
char filename[UTIL_PATH_SIZE];
}
break;
case 'h':
- printf("Usage: udevadm test OPTIONS <syspath>\n"
- " -a,--action=ACTION set action string\n"
- " -N,--resolve-names=early|late|never when to resolve names\n"
- " -h,--help print this help string\n"
- "\n");
+ help();
exit(EXIT_SUCCESS);
case '?':
exit(EXIT_FAILURE);
strscpy(filename, sizeof(filename), syspath);
util_remove_trailing_chars(filename, '/');
- dev = udev_device_new_from_syspath(udev, filename);
+ dev = udev_device_new_from_synthetic_event(udev, filename, action);
if (dev == NULL) {
fprintf(stderr, "unable to open device '%s'\n", filename);
rc = 4;
goto out;
}
- /* skip reading of db, but read kernel parameters */
+ /* don't read info from the db */
udev_device_set_info_loaded(dev);
- udev_device_read_uevent_file(dev);
- udev_device_set_action(dev, action);
event = udev_event_new(dev);
sigfillset(&mask);
const struct udevadm_cmd udevadm_test = {
.name = "test",
.cmd = adm_test,
- .help = "test an event run",
+ .help = "Test an event run",
.debug = true,
};