summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousa@expertisesolutions.com.br>2019-04-05 19:57:29 -0300
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2019-04-05 19:58:19 -0300
commit1c22a3d8190fd85570418a076356547f3eda606f (patch)
treec22410a67a3b7263b495ce9ae0ae24d5e8b1daf9 /src/tests
parent1e22db1150049e313bcba7906fc5ffc9a745eaf0 (diff)
efl-csharp: fix resource deallocation causing errors everywhere
Summary: This commit mainly fixes errors caused by deallocating resources in the garbage collector thread. Using `ecore_main_loop_thread_safe_call_async` to queue resource deallocation in the main thread seems to solve it. Also, some `efl_ref` calls are added in places they were missing, mainly objects that unref in the destructor thus taking ownership if efl_ref is not called. Also fix improper resource deallocation in tests that were causing it to crash, enabling it to call Efl.All.Shutdown again. This allocation and the deallocation process was moved from the Eo class constructor to static class methods that are called in the test 'set up' and 'tear down' methods. Queuing resource deallocation in the main thread make it mandatory that tests call `Efl.App.AppMain.Iterate()` if they want to check proper resource deallocation (like TestFunctionPointers.set_callback_inherited_called_from_c). Extras: Remove duplicated declaration of 'eflcustomexportsmono' in meson in order to fix some linking problems. Remove some unused code around deallocation functions that had to be reworked. Object allocation is now supplied with the call site information it expects (file name and line for _efl_add_start). Depends on D8550 Test Plan: meson test Reviewers: felipealmeida, lauromoura, cedric, segfaultxavi Reviewed By: lauromoura Subscribers: segfaultxavi Tags: #efl_language_bindings, #do_not_merge Differential Revision: https://phab.enlightenment.org/D8431
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/efl_mono/Eina.cs30
-rw-r--r--src/tests/efl_mono/FunctionPointers.cs1
-rw-r--r--src/tests/efl_mono/Main.cs2
-rw-r--r--src/tests/efl_mono/dummy_test_object.eo8
-rw-r--r--src/tests/efl_mono/libefl_mono_native_test.c10
5 files changed, 42 insertions, 9 deletions
diff --git a/src/tests/efl_mono/Eina.cs b/src/tests/efl_mono/Eina.cs
index 6a07e2f288..1705c7ab83 100644
--- a/src/tests/efl_mono/Eina.cs
+++ b/src/tests/efl_mono/Eina.cs
@@ -454,6 +454,16 @@ class TestEinaSlice
454 454
455class TestEinaArray 455class TestEinaArray
456{ 456{
457 public static void SetUp()
458 {
459 Dummy.TestObject.CreateCmpArrayObjects();
460 }
461
462 public static void TearDown()
463 {
464 Dummy.TestObject.DestroyCmpArrayObjects();
465 }
466
457 public static void eina_array_default() 467 public static void eina_array_default()
458 { 468 {
459 var a = new Eina.Array<int>(); 469 var a = new Eina.Array<int>();
@@ -1273,6 +1283,16 @@ class TestEinaInarray
1273 1283
1274class TestEinaList 1284class TestEinaList
1275{ 1285{
1286 public static void SetUp()
1287 {
1288 Dummy.TestObject.CreateCmpArrayObjects();
1289 }
1290
1291 public static void TearDown()
1292 {
1293 Dummy.TestObject.DestroyCmpArrayObjects();
1294 }
1295
1276 public static void data_set_int() 1296 public static void data_set_int()
1277 { 1297 {
1278 var lst = new Eina.List<int>(); 1298 var lst = new Eina.List<int>();
@@ -2547,6 +2567,16 @@ class TestEinaHash
2547 2567
2548class TestEinaIterator 2568class TestEinaIterator
2549{ 2569{
2570 public static void SetUp()
2571 {
2572 Dummy.TestObject.CreateCmpArrayObjects();
2573 }
2574
2575 public static void TearDown()
2576 {
2577 Dummy.TestObject.DestroyCmpArrayObjects();
2578 }
2579
2550 // Array // 2580 // Array //
2551 2581
2552 public static void eina_array_int_empty_iterator() 2582 public static void eina_array_int_empty_iterator()
diff --git a/src/tests/efl_mono/FunctionPointers.cs b/src/tests/efl_mono/FunctionPointers.cs
index de363c86d6..4536704389 100644
--- a/src/tests/efl_mono/FunctionPointers.cs
+++ b/src/tests/efl_mono/FunctionPointers.cs
@@ -173,6 +173,7 @@ class TestFunctionPointers
173 173
174 GC.Collect(); 174 GC.Collect();
175 GC.WaitForPendingFinalizers(); 175 GC.WaitForPendingFinalizers();
176 Efl.App.AppMain.Iterate();
176 177
177 Test.Assert(obj.set_called, "set_callback override must have been called"); 178 Test.Assert(obj.set_called, "set_callback override must have been called");
178 Test.Assert(!obj.invoke_called, "invoke_callback must not have been called"); 179 Test.Assert(!obj.invoke_called, "invoke_callback must not have been called");
diff --git a/src/tests/efl_mono/Main.cs b/src/tests/efl_mono/Main.cs
index 3ae3584798..a5700ff180 100644
--- a/src/tests/efl_mono/Main.cs
+++ b/src/tests/efl_mono/Main.cs
@@ -92,6 +92,8 @@ class TestMain
92 } 92 }
93 Console.WriteLine("[ END SUITE ] " + ckRunSuite); 93 Console.WriteLine("[ END SUITE ] " + ckRunSuite);
94 94
95 Efl.All.Shutdown();
96
95 if (!pass) 97 if (!pass)
96 return -1; 98 return -1;
97 99
diff --git a/src/tests/efl_mono/dummy_test_object.eo b/src/tests/efl_mono/dummy_test_object.eo
index eabb6cd0ce..a50c70e2e6 100644
--- a/src/tests/efl_mono/dummy_test_object.eo
+++ b/src/tests/efl_mono/dummy_test_object.eo
@@ -1356,6 +1356,12 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface {
1356 } 1356 }
1357 } 1357 }
1358 1358
1359 create_cmp_array_objects @class {
1360 }
1361
1362 destroy_cmp_array_objects @class {
1363 }
1364
1359 /* Futures */ 1365 /* Futures */
1360 1366
1361 get_future { 1367 get_future {
@@ -1405,8 +1411,6 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface {
1405 } 1411 }
1406 } 1412 }
1407 implements { 1413 implements {
1408 class.constructor;
1409 class.destructor;
1410 Efl.Object.constructor; 1414 Efl.Object.constructor;
1411 Efl.Object.provider_find; 1415 Efl.Object.provider_find;
1412 Dummy.Test_Iface.emit_nonconflicted; 1416 Dummy.Test_Iface.emit_nonconflicted;
diff --git a/src/tests/efl_mono/libefl_mono_native_test.c b/src/tests/efl_mono/libefl_mono_native_test.c
index 8575ebac9c..17ef5065b2 100644
--- a/src/tests/efl_mono/libefl_mono_native_test.c
+++ b/src/tests/efl_mono/libefl_mono_native_test.c
@@ -3640,12 +3640,11 @@ Dummy_StructComplex* _dummy_test_object_struct_complex_ptr_return_own(EINA_UNUSE
3640} 3640}
3641 3641
3642// // 3642// //
3643// Class constructor 3643// Class methods
3644// // 3644// //
3645EOLIAN static void 3645EOLIAN static void
3646_dummy_test_object_class_constructor(Efl_Class *klass) 3646_dummy_test_object_create_cmp_array_objects(void)
3647{ 3647{
3648 (void)klass;
3649 modified_seq_obj[0] = base_seq_obj[0] = _new_obj(0x0); 3648 modified_seq_obj[0] = base_seq_obj[0] = _new_obj(0x0);
3650 modified_seq_obj[1] = base_seq_obj[1] = _new_obj(0x2A); 3649 modified_seq_obj[1] = base_seq_obj[1] = _new_obj(0x2A);
3651 modified_seq_obj[2] = base_seq_obj[2] = _new_obj(0x42); 3650 modified_seq_obj[2] = base_seq_obj[2] = _new_obj(0x42);
@@ -3655,11 +3654,8 @@ _dummy_test_object_class_constructor(Efl_Class *klass)
3655} 3654}
3656 3655
3657EOLIAN static void 3656EOLIAN static void
3658_dummy_test_object_class_destructor(Efl_Class *klass) 3657_dummy_test_object_destroy_cmp_array_objects(void)
3659{ 3658{
3660 (void)klass;
3661 for (unsigned i = 0; i < base_seq_obj_size; ++i)
3662 efl_unref(base_seq_obj[i]);
3663 for (unsigned i = 0; i < modified_seq_obj_size; ++i) 3659 for (unsigned i = 0; i < modified_seq_obj_size; ++i)
3664 efl_unref(modified_seq_obj[i]); 3660 efl_unref(modified_seq_obj[i]);
3665} 3661}