Beispiel #1
0
void test_readWrite (const char * fileName, KeySet * conf)
{
	printf ("Test read write with %s\n", srcdir_file (fileName));

	Plugin * plugin = elektraPluginOpen ("yajl", modules, conf, 0);
	exit_if_fail (plugin != 0, "could not open plugin");
	// printf ("Test with %s\n", srcdir_file(fileName));

	Key * parentKey = keyNew ("user/tests/yajl", KEY_VALUE, srcdir_file (fileName), KEY_END);
	KeySet * keys = ksNew (0, KS_END);
	succeed_if (plugin->kdbGet (plugin, keys, parentKey) == 1, "kdbGet was not successful");
	succeed_if (output_error (parentKey), "error in kdbGet");
	succeed_if (output_warnings (parentKey), "warnings in kdbGet");

	// output_keyset(keys);

	keySetString (parentKey, elektraFilename ());
	// keySetString(parentKey, "/proc/self/fd/1");
	// printf("File name is: %s\n", keyString(parentKey));

	succeed_if (plugin->kdbSet (plugin, keys, parentKey) == 1, "kdbSet was not successful");
	succeed_if (output_error (parentKey), "error in kdbSet");
	succeed_if (output_warnings (parentKey), "warnings in kdbSet");

	succeed_if (compare_line_files (srcdir_file (fileName), keyString (parentKey)), "files do not match as expected");
	elektraUnlink (keyString (parentKey));

	keyDel (parentKey);
	ksDel (keys);

	elektraPluginClose (plugin, 0);
}
Beispiel #2
0
void test_hostLensFormatting(char *fileName)
{
	Key *parentKey = keyNew ("user/tests/augeas-hosts", KEY_VALUE,
			srcdir_file (fileName), KEY_END);
	KeySet *conf = ksNew (20,
			keyNew ("system/lens", KEY_VALUE, "Hosts.lns", KEY_END), KS_END);
	PLUGIN_OPEN("augeas");

	KeySet *ks = ksNew(0, KS_END);

	succeed_if(plugin->kdbGet (plugin, ks, parentKey) >= 1,
			"call to kdbGet was not successful");
	succeed_if(output_error (parentKey), "error in kdbGet");
	succeed_if(output_warnings (parentKey), "warnings in kdbGet");

	keySetString (parentKey, elektraFilename());

	succeed_if(plugin->kdbSet (plugin, ks, parentKey) == 1,
			"kdbSet was not successful");
	succeed_if(output_error (parentKey), "error in kdbSet");
	succeed_if(output_warnings (parentKey), "warnings in kdbSet");

	succeed_if(
			compare_line_files (srcdir_file (fileName), keyString (parentKey)),
			"files do not match as expected");

	elektraUnlink(keyString (parentKey));
	keyDel (parentKey);
	ksDel (ks);


	PLUGIN_CLOSE ()
	;

}
Beispiel #3
0
void test_hostLensDelete(char *sourceFile, char *compFile)
{
	Key *parentKey = keyNew ("user/tests/augeas-hosts", KEY_VALUE,
			srcdir_file (sourceFile), KEY_END);
	KeySet *conf = ksNew (20,
			keyNew ("system/lens", KEY_VALUE, "Hosts.lns", KEY_END), KS_END);
	PLUGIN_OPEN("augeas");

	KeySet *ks = ksNew(0, KS_END);

	succeed_if(plugin->kdbGet (plugin, ks, parentKey) >= 1,
			"call to kdbGet was not successful");
	succeed_if(output_error (parentKey), "error in kdbGet");
	succeed_if(output_warnings (parentKey), "warnings in kdbGet");

	Key *key = ksLookupByName (ks, "user/tests/augeas-hosts/1", 0);
	exit_if_fail(key, "localhost not found");
	ksPopAtCursor(ks, ksGetCursor(ks));
	keyDel (key);

	key = ksLookupByName (ks, "user/tests/augeas-hosts/1/ipaddr", 0);
	exit_if_fail(key, "ip address of localhost not found");
	ksPopAtCursor(ks, ksGetCursor(ks));
	keyDel (key);

	key = ksLookupByName (ks, "user/tests/augeas-hosts/1/canonical", 0);
	exit_if_fail(key, "canonical of localhost not found");
	ksPopAtCursor(ks, ksGetCursor(ks));
	keyDel (key);

	key = ksLookupByName (ks, "user/tests/augeas-hosts/1/#comment", 0);
	exit_if_fail(key, "comment of localhost not found");
	ksPopAtCursor(ks, ksGetCursor(ks));
	keyDel (key);

	keySetString (parentKey, elektraFilename());

	succeed_if(plugin->kdbSet (plugin, ks, parentKey) == 1,
			"kdbSet was not successful");
	succeed_if(output_error (parentKey), "error in kdbSet");
	succeed_if(output_warnings (parentKey), "warnings in kdbSet");

	succeed_if(
			compare_line_files (srcdir_file (compFile), keyString (parentKey)),
			"files do not match as expected");

	ksDel (ks);

	elektraUnlink(keyString (parentKey));
	keyDel (parentKey);

	PLUGIN_CLOSE ()
	;

}
Beispiel #4
0
void test_hostLensWrite(char *fileName)
{
	Key *parentKey = keyNew ("user/tests/augeas-hosts", KEY_VALUE,
			elektraFilename(), KEY_END);
	KeySet *conf = ksNew (20,
			keyNew ("system/lens", KEY_VALUE, "Hosts.lns", KEY_END), KS_END);
	PLUGIN_OPEN("augeas");

	KeySet *ks = ksNew (30, keyNew ("user/tests/augeas-hosts/1", KEY_END),
			keyNew ("user/tests/augeas-hosts/1/ipaddr", KEY_VALUE, "127.0.0.1",
					KEY_META, "order", "10", KEY_END),
			keyNew ("user/tests/augeas-hosts/1/canonical", KEY_VALUE,
					"localhost", KEY_META, "order", "20", KEY_END),
			keyNew ("user/tests/augeas-hosts/1/#comment", KEY_VALUE,
					"hostcomment", KEY_META, "order", "21", KEY_END),
			keyNew ("user/tests/augeas-hosts/#comment", KEY_VALUE,
					"linecomment", KEY_META, "order", "22", KEY_END),
			keyNew ("user/tests/augeas-hosts/2/ipaddr", KEY_VALUE,
					"192.168.0.1", KEY_META, "order", "30", KEY_END),
			keyNew ("user/tests/augeas-hosts/2/canonical", KEY_VALUE, "host1",
					KEY_META, "order", "40", KEY_END),
			keyNew ("user/tests/augeas-hosts/2/alias[1]", KEY_VALUE,
					"host1alias1", KEY_META, "order", "50", KEY_END),
			keyNew ("user/tests/augeas-hosts/2/alias[2]", KEY_VALUE,
					"host1alias2", KEY_META, "order", "60", KEY_END),
			keyNew ("user/tests/augeas-hosts/3/ipaddr", KEY_VALUE,
					"fd00::4711:4712:2::1", KEY_META, "order", "70", KEY_END),
			keyNew ("user/tests/augeas-hosts/3/canonical", KEY_VALUE, "host2",
					KEY_META, "order", "80", KEY_END),
			keyNew ("user/tests/augeas-hosts/3/alias[1]", KEY_VALUE,
					"host2alias1", KEY_META, "order", "90", KEY_END),
			keyNew ("user/tests/augeas-hosts/3/alias[2]", KEY_VALUE,
					"host2alias2", KEY_META, "order", "100", KEY_END), KS_END);

	ksAppendKey (ks, parentKey);

	succeed_if(plugin->kdbSet (plugin, ks, parentKey) == 1,
			"kdbSet was not successful");
	succeed_if(output_error (parentKey), "error in kdbSet");
	succeed_if(output_warnings (parentKey), "warnings in kdbSet");

	succeed_if(
			compare_line_files (srcdir_file (fileName), keyString (parentKey)),
			"files do not match as expected");

	elektraUnlink(keyString (parentKey));

	ksDel (ks);

	PLUGIN_CLOSE ();
}
void test_writefstab (const char * file)
{
	KeySet * conf = 0;
	PLUGIN_OPEN ("fstab");

	printf ("Writing fstab using file: %s\n", file);

	KeySet * ks = ksNew (
		22, keyNew ("user/tests/filesystems", KEY_VALUE, "filesystems", KEY_COMMENT, "", KEY_END),
		keyNew ("user/tests/filesystems/\\/", KEY_VALUE, "the root fs", KEY_COMMENT, "pseudo name", KEY_END),
		keyNew ("user/tests/filesystems/\\//device", KEY_VALUE, "/dev/sda6", KEY_COMMENT, "Device or Label", KEY_END),
		keyNew ("user/tests/filesystems/\\//dumpfreq", KEY_VALUE, "0", KEY_COMMENT, "Dump frequency in days", KEY_END),
		keyNew ("user/tests/filesystems/\\//mpoint", KEY_VALUE, "/", KEY_COMMENT, "Moint point", KEY_END),
		keyNew ("user/tests/filesystems/\\//options", KEY_VALUE, "defaults,errors=remount-ro", KEY_COMMENT,
			"Fileuser/tests specific options. See mount(8)", KEY_END),
		keyNew ("user/tests/filesystems/\\//passno", KEY_VALUE, "1", KEY_COMMENT, "Pass number on parallel fsck", KEY_END),
		keyNew ("user/tests/filesystems/\\//type", KEY_VALUE, "jfs", KEY_COMMENT, "Fileuser/tests type. See fs(5)", KEY_END),
		keyNew ("user/tests/filesystems/swap00", KEY_VALUE, "non-swapfs", KEY_COMMENT, "pseudo name", KEY_END),
		keyNew ("user/tests/filesystems/swap00/device", KEY_VALUE, "/dev/sda10", KEY_COMMENT, "Device or Label", KEY_END),
		keyNew ("user/tests/filesystems/swap00/dumpfreq", KEY_VALUE, "0", KEY_COMMENT, "Dump frequency in days", KEY_END),
		keyNew ("user/tests/filesystems/swap00/mpoint", KEY_VALUE, "none", KEY_COMMENT, "Moint point", KEY_END),
		keyNew ("user/tests/filesystems/swap00/options", KEY_VALUE, "sw", KEY_COMMENT,
			"Fileuser/tests specific options. See mount(8)", KEY_END),
		keyNew ("user/tests/filesystems/swap00/passno", KEY_VALUE, "0", KEY_COMMENT, "Pass number on parallel fsck", KEY_END),
		keyNew ("user/tests/filesystems/swap00/type", KEY_VALUE, "swap", KEY_COMMENT, "Fileuser/tests type. See fs(5)", KEY_END),
		KS_END);

	Key * parentKey = keyNew ("user/tests/filesystems", KEY_VALUE, elektraFilename (), KEY_END);
	succeed_if (plugin->kdbSet (plugin, ks, parentKey) == 1, "kdbSet was not successful");
	succeed_if (output_error (parentKey), "error in kdbSet");
	succeed_if (output_warnings (parentKey), "warnings in kdbSet");

	succeed_if (compare_line_files (srcdir_file (file), keyString (parentKey)), "files do not match as expected");

	elektraUnlink (keyString (parentKey));
	keyDel (parentKey);

	ksDel (ks);

	PLUGIN_CLOSE ();
}