[retro-gtk] reftest: Add the NoStateAccess test



commit e6c43ed0c5f0710ea57ba84a3369575c4b4ab7b7
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Wed Apr 25 16:08:08 2018 +0200

    reftest: Add the NoStateAccess test
    
    This will check that the core's state can't be accessed. This can be
    used on cores not implementing serialization yet to know that they
    implemented it via a failure of the test.

 tests/retro-reftest.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
---
diff --git a/tests/retro-reftest.c b/tests/retro-reftest.c
index d43ef31..e1d04e3 100644
--- a/tests/retro-reftest.c
+++ b/tests/retro-reftest.c
@@ -267,6 +267,13 @@ retro_reftest_test_run (RetroReftestRun *run)
   g_assert_cmpuint (target_frame + 1, ==, next_frame);
 }
 
+static void
+retro_reftest_test_no_state_access (RetroReftestData *data)
+{
+  if (retro_core_get_can_access_state (data->core))
+    g_test_fail ();
+}
+
 static void
 retro_reftest_test_state_refresh (RetroReftestData *data)
 {
@@ -394,6 +401,23 @@ retro_reftest_add_run_test (RetroReftestFile *reftest_file,
   g_free (test_path);
 }
 
+static void
+retro_reftest_add_no_state_access_test (RetroReftestFile *reftest_file,
+                                        guint             frame_number,
+                                        RetroReftestData *data)
+{
+  gchar *test_path;
+
+  test_path = g_strdup_printf ("%s/%u/NoStateAccess",
+                               retro_reftest_file_peek_path (reftest_file),
+                               frame_number);
+  g_test_add_data_func_full (test_path,
+                             retro_reftest_data_ref (data),
+                             (GTestDataFunc) retro_reftest_test_no_state_access,
+                             (GDestroyNotify) retro_reftest_data_unref);
+  g_free (test_path);
+}
+
 static void
 retro_reftest_add_state_refresh_test (RetroReftestFile *reftest_file,
                                       guint             frame_number,
@@ -480,6 +504,8 @@ retro_reftest_setup_for_file (GFile *file)
     for (tests_i = 0; tests != NULL && tests[tests_i] != NULL; tests_i++) {
       if (g_str_equal (tests[tests_i], "Run"))
         retro_reftest_add_run_test (reftest_file, frame_number, data);
+      else if (g_str_equal (tests[tests_i], "NoStateAccess"))
+        retro_reftest_add_no_state_access_test (reftest_file, frame_number, data);
       else if (g_str_equal (tests[tests_i], "StateRefresh"))
         retro_reftest_add_state_refresh_test (reftest_file, frame_number, data);
       else if (g_str_equal (tests[tests_i], "Video"))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]