aports/community/upower/0001-fix-self-test-sleep-duration.patch

79 lines
3.1 KiB
Diff

# longaarch64 only - related issue: https://gitlab.freedesktop.org/upower/upower/-/issues/195
diff --git a/src/up-self-test.c b/src/up-self-test.c
index f60618f..3f39c12 100644
--- a/src/up-self-test.c
+++ b/src/up-self-test.c
@@ -172,20 +172,20 @@ up_test_history_func (void)
up_history_set_time_empty_data (history, 12346);
up_history_set_time_full_data (history, 54322);
- g_usleep (2 * G_USEC_PER_SEC);
+ g_usleep (5 * G_USEC_PER_SEC);
up_history_set_charge_data (history, 90);
up_history_set_rate_data (history, 1.00f);
up_history_set_time_empty_data (history, 12345);
up_history_set_time_full_data (history, 54321);
- g_usleep (2 * G_USEC_PER_SEC);
+ g_usleep (5 * G_USEC_PER_SEC);
up_history_set_charge_data (history, 95);
up_history_set_rate_data (history, 1.01f);
up_history_set_time_empty_data (history, 12344);
up_history_set_time_full_data (history, 54320);
- /* get data for last 10 seconds */
- array = up_history_get_data (history, UP_HISTORY_TYPE_CHARGE, 10, 100);
+ /* get data for last 20 seconds */
+ array = up_history_get_data (history, UP_HISTORY_TYPE_CHARGE, 20, 100);
g_assert (array != NULL);
g_assert_cmpint (array->len, ==, 3);
@@ -212,7 +212,7 @@ up_test_history_func (void)
/* request fewer items than we have in our history; should have the
* same order: first one is the most recent, and the data gets
* interpolated */
- array = up_history_get_data (history, UP_HISTORY_TYPE_CHARGE, 10, 2);
+ array = up_history_get_data (history, UP_HISTORY_TYPE_CHARGE, 20, 2);
g_assert (array != NULL);
g_assert_cmpint (array->len, ==, 2);
@@ -242,8 +242,8 @@ up_test_history_func (void)
up_history_set_directory (history, history_dir);
up_history_set_id (history, "test");
- /* get data for last 10 seconds */
- array = up_history_get_data (history, UP_HISTORY_TYPE_CHARGE, 10, 100);
+ /* get data for last 20 seconds */
+ array = up_history_get_data (history, UP_HISTORY_TYPE_CHARGE, 20, 100);
g_assert (array != NULL);
g_assert_cmpint (array->len, ==, 4); /* we have inserted an unknown as the first entry */
item = g_ptr_array_index (array, 1);
@@ -253,17 +253,23 @@ up_test_history_func (void)
g_ptr_array_unref (array);
/* ensure old entries are purged */
- up_history_set_max_data_age (history, 2);
- g_usleep (1100 * G_USEC_PER_SEC / 1000);
+ up_history_set_max_data_age (history, 5);
+ g_usleep (G_USEC_PER_SEC);
g_object_unref (history);
- /* ensure only 2 points are returned */
+ /* ensure only 2 points are returned (the two inserted UNKNOWN state points are compressed) */
history = up_history_new ();
up_history_set_directory (history, history_dir);
up_history_set_id (history, "test");
- array = up_history_get_data (history, UP_HISTORY_TYPE_CHARGE, 10, 100);
+ array = up_history_get_data (history, UP_HISTORY_TYPE_CHARGE, 20, 100);
g_assert (array != NULL);
g_assert_cmpint (array->len, ==, 2);
+
+ item = g_ptr_array_index (array, 0);
+ g_assert_cmpint (up_history_item_get_value (item), ==, 0);
+ item = g_ptr_array_index (array, 1);
+ g_assert_cmpint (up_history_item_get_value (item), ==, 0);
+
g_ptr_array_unref (array);
/* unref */