From ace1a12d0f23c1c16614eb9832094777861367c6 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 31 May 2018 19:36:45 +0100 Subject: [PATCH 14/39] containers test: Move teardown below all test-cases Signed-off-by: Simon McVittie --- test/containers.c | 106 +++++++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/test/containers.c b/test/containers.c index acac82a4..18c2f241 100644 --- a/test/containers.c +++ b/test/containers.c @@ -1514,6 +1514,59 @@ test_max_connections_per_container (Fixture *f, #endif /* !HAVE_CONTAINERS_TEST */ } +/* + * Test what happens when we exceed max_container_metadata_bytes. + * test_metadata() exercises the non-excessive case with the same + * configuration. + */ +static void +test_max_container_metadata_bytes (Fixture *f, + gconstpointer context) +{ +#ifdef HAVE_CONTAINERS_TEST + /* Must be >= max_container_metadata_bytes in limit-containers.conf, so that + * when the serialization overhead, app-container type and app name are + * added, it is too much for the limit */ + guchar waste_of_space[4096] = { 0 }; + GVariant *tuple; + GVariant *parameters; + GVariantDict dict; + + if (f->skip) + return; + + f->proxy = g_dbus_proxy_new_sync (f->unconfined_conn, + G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, + NULL, DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, DBUS_INTERFACE_CONTAINERS1, + NULL, &f->error); + g_assert_no_error (f->error); + + g_variant_dict_init (&dict, NULL); + g_variant_dict_insert (&dict, "waste of space", "@ay", + g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, + waste_of_space, + sizeof (waste_of_space), + 1)); + + /* Floating reference, call_..._sync takes ownership */ + parameters = g_variant_new ("(ss@a{sv}a{sv})", + "com.wasteheadquarters", + "Packt Like Sardines in a Crushd Tin Box", + g_variant_dict_end (&dict), + NULL); /* no named arguments */ + + tuple = g_dbus_proxy_call_sync (f->proxy, "AddServer", parameters, + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &f->error); + g_assert_error (f->error, G_DBUS_ERROR, G_DBUS_ERROR_LIMITS_EXCEEDED); + g_assert_null (tuple); + g_clear_error (&f->error); + +#else /* !HAVE_CONTAINERS_TEST */ + g_test_skip ("Containers or gio-unix-2.0 not supported"); +#endif /* !HAVE_CONTAINERS_TEST */ +} + static void teardown (Fixture *f, gconstpointer context G_GNUC_UNUSED) @@ -1590,59 +1643,6 @@ teardown (Fixture *f, test_main_context_unref (f->ctx); } -/* - * Test what happens when we exceed max_container_metadata_bytes. - * test_metadata() exercises the non-excessive case with the same - * configuration. - */ -static void -test_max_container_metadata_bytes (Fixture *f, - gconstpointer context) -{ -#ifdef HAVE_CONTAINERS_TEST - /* Must be >= max_container_metadata_bytes in limit-containers.conf, so that - * when the serialization overhead, app-container type and app name are - * added, it is too much for the limit */ - guchar waste_of_space[4096] = { 0 }; - GVariant *tuple; - GVariant *parameters; - GVariantDict dict; - - if (f->skip) - return; - - f->proxy = g_dbus_proxy_new_sync (f->unconfined_conn, - G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, - NULL, DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, DBUS_INTERFACE_CONTAINERS1, - NULL, &f->error); - g_assert_no_error (f->error); - - g_variant_dict_init (&dict, NULL); - g_variant_dict_insert (&dict, "waste of space", "@ay", - g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, - waste_of_space, - sizeof (waste_of_space), - 1)); - - /* Floating reference, call_..._sync takes ownership */ - parameters = g_variant_new ("(ss@a{sv}a{sv})", - "com.wasteheadquarters", - "Packt Like Sardines in a Crushd Tin Box", - g_variant_dict_end (&dict), - NULL); /* no named arguments */ - - tuple = g_dbus_proxy_call_sync (f->proxy, "AddServer", parameters, - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &f->error); - g_assert_error (f->error, G_DBUS_ERROR, G_DBUS_ERROR_LIMITS_EXCEEDED); - g_assert_null (tuple); - g_clear_error (&f->error); - -#else /* !HAVE_CONTAINERS_TEST */ - g_test_skip ("Containers or gio-unix-2.0 not supported"); -#endif /* !HAVE_CONTAINERS_TEST */ -} - static const Config stop_server_explicitly = { "valid-config-files/multi-user.conf", -- 2.17.0