platform: share main function among tests

This commit is contained in:
Pavel Šimerda 2013-06-21 04:01:44 +02:00
parent 24dee51bce
commit 35dd05cc43
5 changed files with 33 additions and 64 deletions

View file

@ -218,22 +218,9 @@ test_ip6_address_external (void)
free_signal (address_removed);
}
int
main (int argc, char **argv)
void
setup_tests (void)
{
int result;
openlog (G_LOG_DOMAIN, LOG_CONS | LOG_PERROR, LOG_DAEMON);
g_type_init ();
g_test_init (&argc, &argv, NULL);
/* Enable debug messages if called with --debug */
for (; *argv; argv++)
if (!g_strcmp0 (*argv, "--debug"))
nm_logging_setup ("debug", NULL, NULL);
SETUP ();
/* Clean up */
nm_platform_link_delete_by_name (DEVICE_NAME);
g_assert (!nm_platform_link_exists (DEVICE_NAME));
nm_platform_dummy_add (DEVICE_NAME);
@ -245,10 +232,4 @@ main (int argc, char **argv)
g_test_add_func ("/address/external/ip4", test_ip4_address_external);
g_test_add_func ("/address/external/ip6", test_ip6_address_external);
}
result = g_test_run ();
nm_platform_link_delete_by_name (DEVICE_NAME);
nm_platform_free ();
return result;
}

View file

@ -59,3 +59,27 @@ run_command (const char *format, ...)
g_free (command);
}
int
main (int argc, char **argv)
{
int result;
openlog (G_LOG_DOMAIN, LOG_CONS | LOG_PERROR, LOG_DAEMON);
g_type_init ();
g_test_init (&argc, &argv, NULL);
/* Enable debug messages if called with --debug */
for (; *argv; argv++) {
if (!g_strcmp0 (*argv, "--debug")) {
nm_logging_setup ("debug", NULL, NULL);
}
}
SETUP ();
setup_tests ();
result = g_test_run ();
nm_platform_free ();
return result;
}

View file

@ -29,3 +29,6 @@ void wait_signal (SignalData *data);
void free_signal (SignalData *data);
void run_command (const char *format, ...);
void setup_tests (void);

View file

@ -561,24 +561,9 @@ test_external (void)
free_signal (link_removed);
}
int
main (int argc, char **argv)
void
setup_tests (void)
{
int result;
openlog (G_LOG_DOMAIN, LOG_CONS | LOG_PERROR, LOG_DAEMON);
g_type_init ();
g_test_init (&argc, &argv, NULL);
/* Enable debug messages if called with --debug */
for (; *argv; argv++) {
if (!g_strcmp0 (*argv, "--debug")) {
nm_logging_setup ("debug", NULL, NULL);
}
}
SETUP ();
/* Clean up */
nm_platform_link_delete_by_name (DEVICE_NAME);
nm_platform_link_delete_by_name (SLAVE_NAME);
nm_platform_link_delete_by_name (PARENT_NAME);
@ -596,9 +581,4 @@ main (int argc, char **argv)
if (strcmp (g_type_name (G_TYPE_FROM_INSTANCE (nm_platform_get ())), "NMFakePlatform"))
g_test_add_func ("/link/external", test_external);
result = g_test_run ();
nm_platform_free ();
return result;
}

View file

@ -196,22 +196,9 @@ test_ip6_route ()
free_signal (route_removed);
}
int
main (int argc, char **argv)
void
setup_tests (void)
{
int result;
openlog (G_LOG_DOMAIN, LOG_CONS | LOG_PERROR, LOG_DAEMON);
g_type_init ();
g_test_init (&argc, &argv, NULL);
/* Enable debug messages if called with --debug */
for (; *argv; argv++)
if (!g_strcmp0 (*argv, "--debug"))
nm_logging_setup ("debug", NULL, NULL);
SETUP ();
/* Clean up */
nm_platform_link_delete_by_name (DEVICE_NAME);
g_assert (!nm_platform_link_exists (DEVICE_NAME));
g_assert (nm_platform_dummy_add (DEVICE_NAME));
@ -219,10 +206,4 @@ main (int argc, char **argv)
g_test_add_func ("/route/ip4", test_ip4_route);
g_test_add_func ("/route/ip6", test_ip6_route);
result = g_test_run ();
nm_platform_link_delete_by_name (DEVICE_NAME);
nm_platform_free ();
return result;
}