[Libosinfo] [libosinfo PATCH 3/3] test-os: Add tests for osinfo_os_find_install_script()

Christophe Fergeau cfergeau at redhat.com
Mon Dec 10 12:32:57 UTC 2018


I was about to ask about this when seeing the first patch ;)
For what it's worth, I made some slight changes to an existing test in
order to test your changes (before seeing this patch ;), wondering if
this could be useful (I think the only difference is that it adds testing for
<installer> tags in the database)

For your test,
Acked-by: Christophe Fergeau <cfergeau at redhat.com>

The changes I made:

diff --git a/tests/dbdata/os/fedoraproject.org/fedora-16.xml b/tests/dbdata/os/fedoraproject.org/fedora-16.xml
index 88ef4319..90ba9a86 100644
--- a/tests/dbdata/os/fedoraproject.org/fedora-16.xml
+++ b/tests/dbdata/os/fedoraproject.org/fedora-16.xml
@@ -19,5 +19,8 @@
       <kernel>isolinux/vmlinuz</kernel>
       <initrd>isolinux/initrd.img</initrd>
     </media>
+    <installer>
+      <script id="http://example.com/libosinfo/test-install-script"/>
+    </installer>
   </os>
 </libosinfo>
diff --git a/tests/test-install-script.c b/tests/test-install-script.c
index 4935c326..adc11db4 100644
--- a/tests/test-install-script.c
+++ b/tests/test-install-script.c
@@ -244,8 +244,6 @@ test_script_datamap(void)

     g_assert_nonnull(osinfo_db_get_datamap(db, "http://example.com/libosinfo/test-datamap"));
     g_assert_nonnull(osinfo_db_get_datamap(db, "http://example.com/libosinfo/test-datamap2"));
-    script = osinfo_db_get_install_script(db, "http://example.com/libosinfo/test-install-script");
-    g_assert_nonnull(script);

     config = osinfo_install_config_new("http://example.com");

@@ -269,11 +267,16 @@ test_script_datamap(void)
     osinfo_install_config_set_l10n_language(config, "fr_FR");
     osinfo_install_config_set_l10n_timezone(config, "Europe/Paris");

-    os = osinfo_os_new("http://fedoraproject.org/fedora/16");
+    os = osinfo_db_get_os(db, "http://fedoraproject.org/fedora/16");
     osinfo_entity_set_param(OSINFO_ENTITY(os),
                             OSINFO_PRODUCT_PROP_SHORT_ID,
                             "fedora16");

+    script = osinfo_os_find_install_script(os, "default");
+    g_assert_null(script);
+    script = osinfo_os_find_install_script(os, OSINFO_INSTALL_SCRIPT_PROFILE_JEOS);
+    g_assert_nonnull(script);
+    g_assert(script == osinfo_db_get_install_script(db, "http://example.com/libosinfo/test-install-script"));
     loop = g_main_loop_new(g_main_context_get_thread_default(),
                            FALSE);

@@ -293,7 +296,6 @@ test_script_datamap(void)

     g_free(actualData);
     g_object_unref(db);
-    g_object_unref(os);
     g_object_unref(config);
     g_main_loop_unref(loop);
 }

On Fri, Nov 23, 2018 at 01:49:55PM +0100, Fabiano Fidêncio wrote:
> Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
> ---
>  tests/test-os.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/tests/test-os.c b/tests/test-os.c
> index 0b586b2..fbc01de 100644
> --- a/tests/test-os.c
> +++ b/tests/test-os.c
> @@ -878,6 +878,30 @@ test_resources_inheritance(void)
>  }
>  
>  
> +static void
> +test_find_install_script(void)
> +{
> +    OsinfoOs *os;
> +    OsinfoInstallScript *in, *out;
> +
> +    os = osinfo_os_new("awesome");
> +    in = osinfo_install_script_new_data("script", "jeos", "foo");
> +    osinfo_os_add_install_script(os, in);
> +
> +    out = osinfo_os_find_install_script(os, NULL);
> +    g_assert_null(out);
> +
> +    out = osinfo_os_find_install_script(os, OSINFO_INSTALL_SCRIPT_PROFILE_DESKTOP);
> +    g_assert_null(out);
> +
> +    out = osinfo_os_find_install_script(os, OSINFO_INSTALL_SCRIPT_PROFILE_JEOS);
> +    g_assert_nonnull(out);
> +
> +    g_object_unref(in);
> +    g_object_unref(os);
> +}
> +
> +
>  int
>  main(int argc, char *argv[])
>  {
> @@ -898,6 +922,7 @@ main(int argc, char *argv[])
>                      test_resources_minimum_recommended_maximum);
>      g_test_add_func("/os/resources/uniqueness", test_resources_uniqueness);
>      g_test_add_func("/os/resources/inheritance", test_resources_inheritance);
> +    g_test_add_func("/os/find_install_script", test_find_install_script);
>  
>      /* Upfront so we don't confuse valgrind */
>      osinfo_platform_get_type();
> @@ -908,6 +933,7 @@ main(int argc, char *argv[])
>      osinfo_filter_get_type();
>      osinfo_resources_get_type();
>      osinfo_resourceslist_get_type();
> +    osinfo_install_script_get_type();
>  
>      return g_test_run();
>  }
> -- 
> 2.19.1
> 
> _______________________________________________
> Libosinfo mailing list
> Libosinfo at redhat.com
> https://www.redhat.com/mailman/listinfo/libosinfo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libosinfo/attachments/20181210/44fac413/attachment.sig>


More information about the Libosinfo mailing list