@@ -103,18 +103,22 @@ const struct distro test_dists[] = {
103103 { .name = "sled" , .version = "12.3" },
104104};
105105
106+ const int num_test_dists = sizeof (test_dists ) / sizeof (struct distro );
107+
108+ int
109+ value_strcmp_by_key (sentry_value_t value , const char * key , const char * str )
110+ {
111+ return strcmp (
112+ sentry_value_as_string (sentry_value_get_by_key (value , key )), str );
113+ }
114+
106115int
107116assert_equals_snap (sentry_value_t os_dist )
108117{
109- for (size_t i = 0 ; i < sizeof ( test_dists ) / sizeof ( struct distro ) ; i ++ ) {
118+ for (size_t i = 0 ; i < num_test_dists ; i ++ ) {
110119 const struct distro * expected = & test_dists [i ];
111- if (strcmp (sentry_value_as_string (
112- sentry_value_get_by_key (os_dist , "name" )),
113- expected -> name )
114- == 0
115- && strcmp (sentry_value_as_string (
116- sentry_value_get_by_key (os_dist , "version" )),
117- expected -> version )
120+ if (value_strcmp_by_key (os_dist , "name" , expected -> name ) == 0
121+ && value_strcmp_by_key (os_dist , "version" , expected -> version )
118122 == 0 ) {
119123 return 1 ;
120124 }
@@ -145,6 +149,7 @@ SENTRY_TEST(os_releases_snapshot)
145149
146150 struct dirent * entry ;
147151
152+ int successful_snap_asserts = 0 ;
148153 while ((entry = readdir (test_data_dir )) != NULL ) {
149154 if (entry -> d_type != DT_REG
150155 || strcmp ("CODE_OF_CONDUCT.md" , entry -> d_name ) == 0
@@ -165,10 +170,14 @@ SENTRY_TEST(os_releases_snapshot)
165170 sentry_value_get_by_key (os_dist , "name" )),
166171 sentry_value_as_string (
167172 sentry_value_get_by_key (os_dist , "version" )));
173+ } else {
174+ successful_snap_asserts ++ ;
168175 }
169176 sentry_value_decref (os_dist );
170177 }
171178
179+ TEST_CHECK_INT_EQUAL (successful_snap_asserts , num_test_dists );
180+
172181 closedir (test_data_dir );
173182 sentry__path_free (test_data_path );
174183#endif // !defined(SENTRY_PLATFORM_LINUX) && defined(SENTRY_PLATFORM_ANDROID)
0 commit comments