diff --git a/bin/system-info.c b/bin/system-info.c index 090d01a1523f73b10739410b953a885c94a3dd30..b220516be40399169e4a752388ca39889eafff9a 100644 --- a/bin/system-info.c +++ b/bin/system-info.c @@ -185,6 +185,9 @@ jsonify_library_issues (JsonBuilder *builder, if ((issues & SRT_LIBRARY_ISSUES_INTERNAL_ERROR) != 0) json_builder_add_string_value (builder, "internal-error"); + + if ((issues & SRT_LIBRARY_ISSUES_UNKNOWN_EXPECTATIONS) != 0) + json_builder_add_string_value (builder, "unknown-expectations"); } static void @@ -316,7 +319,7 @@ main (int argc, can_run = srt_system_info_can_run (info, multiarch_tuples[i]); json_builder_add_boolean_value (builder, can_run); - if (can_run && expectations != NULL) + if (can_run) { json_builder_set_member_name (builder, "library-issues-summary"); json_builder_begin_array (builder); diff --git a/helpers/inspect-library.c b/helpers/inspect-library.c index 47ba7c024a5f3c6020a11df536d5257bb338f533..5467eee539825b8ad0135f5d4c528a2d508f85c8 100644 --- a/helpers/inspect-library.c +++ b/helpers/inspect-library.c @@ -327,7 +327,7 @@ main (int argc, print_json_string_content (entry); printf ("\""); } - printf ("\n ],"); + printf ("\n ]"); free (missing_symbols); free (misversioned_symbols); @@ -339,7 +339,7 @@ main (int argc, while (dep_map != NULL && dep_map->l_prev != NULL) dep_map = dep_map->l_prev; - printf ("\n \"dependencies\": ["); + printf (",\n \"dependencies\": ["); first = true; for (; dep_map != NULL; dep_map = dep_map->l_next) { diff --git a/steam-runtime-tools/library.c b/steam-runtime-tools/library.c index 4294f32b004dc1dd564615b82fccd2db577c627d..f22800bfcf076e7a2d34bf0699e55962ef93ed06 100644 --- a/steam-runtime-tools/library.c +++ b/steam-runtime-tools/library.c @@ -440,9 +440,9 @@ srt_check_library_presence (const char *soname, JsonParser *parser = NULL; JsonNode *node = NULL; JsonObject *json; - JsonArray *missing_array; - JsonArray *misversioned_array; - JsonArray *dependencies_array; + JsonArray *missing_array = NULL; + JsonArray *misversioned_array = NULL; + JsonArray *dependencies_array = NULL; GError *error = NULL; GStrv missing_symbols = NULL; GStrv misversioned_symbols = NULL; @@ -470,6 +470,9 @@ srt_check_library_presence (const char *soname, g_return_val_if_reached (SRT_LIBRARY_ISSUES_CANNOT_LOAD); } + if (symbols_path == NULL) + issues |= SRT_LIBRARY_ISSUES_UNKNOWN_EXPECTATIONS; + helper = g_strdup_printf ("%s/%s-inspect-library", _srt_get_helpers_path (), multiarch); argv[0] = helper; @@ -521,7 +524,8 @@ srt_check_library_presence (const char *soname, absolute_path = g_strdup (json_object_get_string_member (json, "path")); - missing_array = json_object_get_array_member (json, "missing_symbols"); + if (json_object_has_member (json, "missing_symbols")) + missing_array = json_object_get_array_member (json, "missing_symbols"); if (missing_array != NULL) { if (json_array_get_length (missing_array) > 0) @@ -536,7 +540,8 @@ srt_check_library_presence (const char *soname, } } - misversioned_array = json_object_get_array_member (json, "misversioned_symbols"); + if (json_object_has_member (json, "misversioned_symbols")) + misversioned_array = json_object_get_array_member (json, "misversioned_symbols"); if (misversioned_array != NULL) { if (json_array_get_length (misversioned_array) > 0) @@ -551,7 +556,8 @@ srt_check_library_presence (const char *soname, } } - dependencies_array = json_object_get_array_member (json, "dependencies"); + if (json_object_has_member (json, "dependencies")) + dependencies_array = json_object_get_array_member (json, "dependencies"); if (dependencies_array != NULL) { dependencies = g_new0 (gchar *, json_array_get_length (dependencies_array) + 1); diff --git a/steam-runtime-tools/library.h b/steam-runtime-tools/library.h index a5608ca93ffa256d6330aab405822f3ad640ad10..4df3d72c5b0bc7c4d70c78dc75ab331182ca5324 100644 --- a/steam-runtime-tools/library.h +++ b/steam-runtime-tools/library.h @@ -54,6 +54,9 @@ GType srt_library_get_type (void); * were available with a different version * @SRT_LIBRARY_ISSUES_INTERNAL_ERROR: Generic internal error, for example * a function has been called with a missing required parameter + * @SRT_LIBRARY_ISSUES_UNKNOWN_EXPECTATIONS: No directory containing + * expected ABIs has been set, so we cannot know which libraries we are + * meant to have found * * A bitfield with flags representing problems with a library, or * %SRT_LIBRARY_ISSUES_NONE (which is numerically zero) if no problems @@ -67,6 +70,7 @@ typedef enum SRT_LIBRARY_ISSUES_MISSING_SYMBOLS = (1 << 1), SRT_LIBRARY_ISSUES_MISVERSIONED_SYMBOLS = (1 << 2), SRT_LIBRARY_ISSUES_INTERNAL_ERROR = (1 << 3), + SRT_LIBRARY_ISSUES_UNKNOWN_EXPECTATIONS = (1 << 4), SRT_LIBRARY_ISSUES_NONE = 0 } SrtLibraryIssues; diff --git a/steam-runtime-tools/system-info.c b/steam-runtime-tools/system-info.c index a331134da96a4127fbc439df82b198334e246a23..bf07f719dcc4bf15ea1dfa108ee656634825cbde 100644 --- a/steam-runtime-tools/system-info.c +++ b/steam-runtime-tools/system-info.c @@ -384,6 +384,12 @@ srt_system_info_check_libraries (SrtSystemInfo *self, g_return_val_if_fail (libraries_out == NULL || *libraries_out == NULL, SRT_LIBRARY_ISSUES_INTERNAL_ERROR); + if (self->expectations == NULL) + { + /* We don't know which libraries to check. */ + return SRT_LIBRARY_ISSUES_UNKNOWN_EXPECTATIONS; + } + abi = ensure_abi (self, multiarch_tuple); /* If we cached already the result, we return it */ @@ -405,8 +411,10 @@ srt_system_info_check_libraries (SrtSystemInfo *self, { g_debug ("An error occurred while opening the symbols directory: %s", error->message); g_clear_error (&error); + ret = SRT_LIBRARY_ISSUES_UNKNOWN_EXPECTATIONS; goto out; } + while ((filename = g_dir_read_name (dir))) { char *line = NULL; @@ -509,7 +517,7 @@ srt_system_info_check_library (SrtSystemInfo *self, ssize_t chars; FILE *fp = NULL; SrtLibraryIssues issues; - GDir *dir; + GDir *dir = NULL; GError *error = NULL; SrtLibraryIssues ret = SRT_LIBRARY_ISSUES_INTERNAL_ERROR; @@ -530,16 +538,19 @@ srt_system_info_check_library (SrtSystemInfo *self, return srt_library_get_issues (library); } - - dir_path = g_build_filename (self->expectations, multiarch_tuple, NULL); - dir = g_dir_open (dir_path, 0, &error); - if (error) + if (self->expectations != NULL) { - g_debug ("An error occurred while opening the symbols directory: %s", error->message); - g_clear_error (&error); - goto out; + dir_path = g_build_filename (self->expectations, multiarch_tuple, NULL); + dir = g_dir_open (dir_path, 0, &error); + + if (error) + { + g_debug ("An error occurred while opening the symbols directory: %s", error->message); + g_clear_error (&error); + } } - while ((filename = g_dir_read_name (dir))) + + while (dir != NULL && (filename = g_dir_read_name (dir))) { if (!g_str_has_suffix (filename, ".symbols")) continue; @@ -590,6 +601,7 @@ srt_system_info_check_library (SrtSystemInfo *self, g_clear_pointer (&line, g_free); g_clear_pointer (&fp, fclose); } + /* The SONAME's symbols file is not available. * We do instead a simple absence/presence check. */ issues = srt_check_library_presence (soname, diff --git a/tests/library.c b/tests/library.c index 78cdd4833d5c77b12738ec3c5ce4a1ef572ad40c..3d5445e703fabb0c238c75f38657a05db1f7db4d 100644 --- a/tests/library.c +++ b/tests/library.c @@ -670,14 +670,18 @@ test_missing_library (Fixture *f, NULL, SRT_LIBRARY_SYMBOLS_FORMAT_PLAIN, NULL); - g_assert_cmpint (issues, ==, SRT_LIBRARY_ISSUES_CANNOT_LOAD); + g_assert_cmpint (issues, ==, + (SRT_LIBRARY_ISSUES_CANNOT_LOAD | + SRT_LIBRARY_ISSUES_UNKNOWN_EXPECTATIONS)); issues = srt_check_library_presence ("libMISSING.so.62", _SRT_MULTIARCH, NULL, SRT_LIBRARY_SYMBOLS_FORMAT_PLAIN, &library); - g_assert_cmpint (issues, ==, SRT_LIBRARY_ISSUES_CANNOT_LOAD); + g_assert_cmpint (issues, ==, + (SRT_LIBRARY_ISSUES_CANNOT_LOAD | + SRT_LIBRARY_ISSUES_UNKNOWN_EXPECTATIONS)); g_assert_cmpstr (srt_library_get_absolute_path (library), ==, NULL); missing_symbols = srt_library_get_missing_symbols (library); @@ -713,7 +717,9 @@ test_missing_arch (Fixture *f, NULL, SRT_LIBRARY_SYMBOLS_FORMAT_PLAIN, &library); - g_assert_cmpint (issues, ==, SRT_LIBRARY_ISSUES_CANNOT_LOAD); + g_assert_cmpint (issues, ==, + (SRT_LIBRARY_ISSUES_CANNOT_LOAD | + SRT_LIBRARY_ISSUES_UNKNOWN_EXPECTATIONS)); g_assert_cmpstr (srt_library_get_absolute_path (library), ==, NULL); missing_symbols = srt_library_get_missing_symbols (library); diff --git a/tests/system-info.c b/tests/system-info.c index 4c44dd12b75aee49bddcfad54952d996fb50c909..8edd66108331dca32c78c64596beb8cd71c1289c 100644 --- a/tests/system-info.c +++ b/tests/system-info.c @@ -586,7 +586,9 @@ library_missing (Fixture *f, _SRT_MULTIARCH, "libMISSING.so.62", &library); - g_assert_cmpint (issues, ==, SRT_LIBRARY_ISSUES_CANNOT_LOAD); + g_assert_cmpint (issues, ==, + (SRT_LIBRARY_ISSUES_CANNOT_LOAD | + SRT_LIBRARY_ISSUES_UNKNOWN_EXPECTATIONS)); check_library_missing_lib_result (library); g_clear_pointer (&library, g_object_unref); @@ -595,7 +597,9 @@ library_missing (Fixture *f, _SRT_MULTIARCH, "libMISSING.so.62", &library); - g_assert_cmpint (issues, ==, SRT_LIBRARY_ISSUES_CANNOT_LOAD); + g_assert_cmpint (issues, ==, + (SRT_LIBRARY_ISSUES_CANNOT_LOAD | + SRT_LIBRARY_ISSUES_UNKNOWN_EXPECTATIONS)); check_library_missing_lib_result (library); g_object_unref (library); @@ -626,13 +630,13 @@ wrong_expectations (Fixture *f, issues = srt_system_info_check_libraries (info, _SRT_MULTIARCH, NULL); - g_assert_cmpint (issues, ==, SRT_LIBRARY_ISSUES_INTERNAL_ERROR); + g_assert_cmpint (issues, ==, SRT_LIBRARY_ISSUES_UNKNOWN_EXPECTATIONS); issues = srt_system_info_check_library (info, _SRT_MULTIARCH, "libz.so.1", NULL); - g_assert_cmpint (issues, ==, SRT_LIBRARY_ISSUES_INTERNAL_ERROR); + g_assert_cmpint (issues, ==, SRT_LIBRARY_ISSUES_UNKNOWN_EXPECTATIONS); g_object_unref (info); }