#include "parser-test.h" #if 0 /* PARSER_EMBEDDED_CONFIG */ set default=6c063c8e48904f2684abde8eea303f41-4.15.2-302.fc28.x86_64 blscfg #endif void run_test(struct parser_test *test) { struct discover_boot_option *opt; struct discover_context *ctx; test_add_dir(test, test->ctx->device, "/boot/loader/entries"); test_add_file_string(test, test->ctx->device, "/boot/loader/entries/6c063c8e48904f2684abde8eea303f41-4.15.2-302.fc28.x86_64.conf", "title Fedora (4.15.2-302.fc28.x86_64) 28 (Twenty Eight)\n" "linux /boot/vmlinuz-4.15.2-302.fc28.x86_64\n" "initrd /boot/initramfs-4.15.2-302.fc28.x86_64.img\n" "options root=/dev/mapper/fedora-root ro rd.lvm.lv=fedora/root\n"); test_read_conf_embedded(test, "/boot/grub2/grub.cfg"); test_run_parser(test, "grub2"); ctx = test->ctx; opt = get_boot_option(ctx, 0); check_is_default(opt); }
initrd /boot/initrd #endif void run_test(struct parser_test *test) { struct discover_boot_option *opt; struct discover_context *ctx; test_read_conf_embedded(test, "/boot/petitboot.conf"); test_run_parser(test, "native"); ctx = test->ctx; check_boot_option_count(ctx, 2); opt = get_boot_option(ctx, 0); check_name(opt, "first"); check_resolved_local_resource(opt->boot_image, ctx->device, "/vmlinuz"); check_args(opt, "console=hvc0"); check_resolved_local_resource(opt->initrd, ctx->device, "/initrd"); check_is_default(opt); opt = get_boot_option(ctx, 1); check_name(opt, "second"); check_resolved_local_resource(opt->boot_image, ctx->device, "/boot/vmlinuz"); check_args(opt, "console=tty0"); check_resolved_local_resource(opt->initrd, ctx->device, "/boot/initrd"); }
/* * return : NULL on invalid or */ KeysAndCmd* gsd_kb_util_parse_gsettings_value (char* gsettings_key, char* string) { if (gsettings_key == NULL) { g_warning ("gsd kb util parse gsettings value:gsettings_key is NULL\n"); return NULL; } if (string == NULL) { g_warning ("gsd kb util parse gsettings value:string is NULL\n"); return NULL; } char* _keystring = NULL; char* _cmdstring = NULL; if (check_is_default(gsettings_key)) { //default key bindings _cmdstring = g_strdup (gsettings_key); _keystring = g_strdup (string); } else { //empty slots: <command> ';' <keys> char* _tmp = strchr (string, KEY_BINDING_DELIMITER); if (_tmp == NULL) //no ';', invalid, return NULL. return NULL; *_tmp = '\0'; //split _str into to two strings. _cmdstring = g_strdup (g_strstrip (string)); _keystring = g_strdup (g_strstrip (_tmp+1)); } if ((_cmdstring == NULL)||(_keystring == NULL)) return NULL; if ((!strlen(_cmdstring))||(!strlen(_keystring))) //either string is 0-length, invalid. return NULL; g_debug ("parse keybindings: %s ----> %s", _keystring, _cmdstring); KeysAndCmd* _kandc_ptr = g_new0 (KeysAndCmd, 1); _kandc_ptr->keystring = _keystring; _kandc_ptr->cmdstring = _cmdstring; return _kandc_ptr; }