Project

General

Profile

Support #39101

lasso unit tests don't compile with check 0.13.x

Added by Jakub Hrozek 6 months ago. Updated 3 months ago.

Status:
Fermé
Priority:
Normal
Category:
-
Target version:
Start date:
20 Jan 2020
Due date:
% Done:

0%

Patch proposed:
No
Planning:
No

Description

With the update of the "check" unit test library to 0.13 we're seeing compilation errors on Fedora. A proposed patch is attached.

0001-Explicitly-define-tests-cases-and-add-them-to-tests.patch View (2.6 KB) Jakub Hrozek, 20 Jan 2020 10:19 AM

Associated revisions

Revision 6a0708ed (diff)
Added by Benjamin Dauvergne 4 months ago

tests: fix compilation with check>0.12 (#39101)

History

#1 Updated by Benjamin Dauvergne 6 months ago

Could you report the compiler errors here ? Problem does not seem to be related with the version of check but more with the version of gcc.

#2 Updated by Benjamin Dauvergne 6 months ago

  • Status changed from Nouveau to Information nécessaire
  • Assignee set to Jakub Hrozek

#3 Updated by Jakub Hrozek 6 months ago

Benjamin Dauvergne a écrit :

Could you report the compiler errors here ? Problem does not seem to be related with the version of check but more with the version of gcc.

It is possible, the reason I was suspecting check was that on my Fedora-30 machine, I was initially unable to reproduce the error, but then after upgrading to check and check-devel from Fedora-32, the error appeared. All the details are here:
https://bugzilla.redhat.com/show_bug.cgi?id=1778645 (I hope all the information are visible even if you don't have a RH bugzilla account).

#4 Updated by Jakub Hrozek 6 months ago

Jakub Hrozek a écrit :

Benjamin Dauvergne a écrit :

Could you report the compiler errors here ? Problem does not seem to be related with the version of check but more with the version of gcc.

It is possible, the reason I was suspecting check was that on my Fedora-30 machine, I was initially unable to reproduce the error, but then after upgrading to check and check-devel from Fedora-32, the error appeared. All the details are here:
https://bugzilla.redhat.com/show_bug.cgi?id=1778645 (I hope all the information are visible even if you don't have a RH bugzilla account).

Aaaand of course I screwed up and copy-pasted the same TestCase all over. Sorry, I'll fix that:
+ tcase_add_test(tc_googleapps_27092010, test01_googleapps_27092010);
+ tcase_add_test(tc_googleapps_27092010, indexed_endpoints_20101008);
+ tcase_add_test(tc_googleapps_27092010, remove_warning_when_parssing_unknown_SNIPPET_LIST_NODES_20111007);
+ tcase_add_test(tc_googleapps_27092010, wrong_endpoint_index_in_artifacts);
+ tcase_add_test(tc_googleapps_27092010, malformed_logout_request);
+

#5 Updated by Benjamin Dauvergne 6 months ago

Looking at the error I'm pretty it's related to gcc 10 which seems used in Fedora 32 and the specific compiler flags used. I looked at the build error (https://koschei.fedoraproject.org/build/7108742) but it does not report difference in GCC version.

#6 Updated by Jakub Hrozek 6 months ago

Benjamin Dauvergne a écrit :

Looking at the error I'm pretty it's related to gcc 10 which seems used in Fedora 32 and the specific compiler flags used. I looked at the build error (https://koschei.fedoraproject.org/build/7108742) but it does not report difference in GCC version.

Perhaps, but I saw the error also locally with the combination of gcc-9.2.1-1.fc30.x86_64 and check-devel-0.13.0-2.fc32.x86_64

#7 Updated by Benjamin Dauvergne 6 months ago

Jakub Hrozek a écrit :

Benjamin Dauvergne a écrit :

Looking at the error I'm pretty it's related to gcc 10 which seems used in Fedora 32 and the specific compiler flags used. I looked at the build error (https://koschei.fedoraproject.org/build/7108742) but it does not report difference in GCC version.

Perhaps, but I saw the error also locally with the combination of gcc-9.2.1-1.fc30.x86_64 and check-devel-0.13.0-2.fc32.x86_64

Ok, I'm going to look what changed between 0.12 and 0.13, in the meantime could you report here flags between a working compilation and a failing one for the same file ?

#8 Updated by Benjamin Dauvergne 6 months ago

  • Status changed from Information nécessaire to En cours
  • Assignee changed from Jakub Hrozek to Benjamin Dauvergne

Ok don't bother I found the breaking change :

 #define START_TEST(__testname)\
-static void __testname (int _i CK_ATTRIBUTE_UNUSED)\
-{\
-  tcase_fn_start (""# __testname, __FILE__, __LINE__);
+static void __testname ## _fn (int _i CK_ATTRIBUTE_UNUSED);\
+static const TTest __testname ## _ttest = {""# __testname, __testname ## _fn, __FILE__, __LINE__};\
+static const TTest * __testname = & __testname ## _ttest;\
+static void __testname ## _fn (int _i CK_ATTRIBUTE_UNUSED)

__testname is not a function anymore, it's a struct referencing the test function.

#9 Updated by Benjamin Dauvergne 6 months ago

Could you test the following patch on Fedora32 ?

diff --git tests/non_regression_tests.c tests/non_regression_tests.c
index d2993ecd..0f9070a1 100644
--- tests/non_regression_tests.c
+++ tests/non_regression_tests.c
@@ -235,7 +235,11 @@ END_TEST

 struct {
        char *name;
-       void *function;
+#if (CHECK_MAJOR_VERSION > 0) || (CHECK_MINOR_VERSION > 12)
+       TTest *test;
+#else
+       void *test;
+#endif
 } tests[] = {
        { "Googleapps error from coudot@ on 27-09-2010", test01_googleapps_27092010},
        { "Wrong assertionConsumer ordering on 08-10-2010", indexed_endpoints_20101008},
@@ -252,8 +256,7 @@ non_regression_suite()

        for (i = 0 ; i < G_N_ELEMENTS(tests); i++) {
                TCase *c = tcase_create(tests[i].name);
-               void *f = tests[i].function;
-               tcase_add_test(c, f);
+               tcase_add_test(c, tests[i].test);
                suite_add_tcase(s, c);
        }

#10 Updated by Jakub Hrozek 6 months ago

Benjamin Dauvergne a écrit :

Could you test the following patch on Fedora32 ?

[...]

I'm sorry, but this doesn't seem to be working. I'm getting:

make[3]: Nothing to be done for 'all'.
non_regression_tests.c:244:51: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  244 |  { "Googleapps error from coudot@ on 27-09-2010", test01_googleapps_27092010},
      |                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
non_regression_tests.c:244:51: error: initializer element is not constant
non_regression_tests.c:244:51: note: (near initialization for 'tests[0].test')
non_regression_tests.c:245:54: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  245 |  { "Wrong assertionConsumer ordering on 08-10-2010", indexed_endpoints_20101008},
      |                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~
non_regression_tests.c:245:54: error: initializer element is not constant
non_regression_tests.c:245:54: note: (near initialization for 'tests[1].test')
non_regression_tests.c:246:83: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  246 |  { "Warning when parsing AttributeValue node containing unknown namespace nodes", remove_warning_when_parssing_unknown_SNIPPET_LIST_NODES_20111007 },
      |                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
non_regression_tests.c:246:83: error: initializer element is not constant
non_regression_tests.c:246:83: note: (near initialization for 'tests[2].test')
non_regression_tests.c:247:41: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  247 |  { "Wrong endpoint index in artifacts", wrong_endpoint_index_in_artifacts },
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
non_regression_tests.c:247:41: error: initializer element is not constant
non_regression_tests.c:247:41: note: (near initialization for 'tests[3].test')
non_regression_tests.c:248:32: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  248 |  { "Malformed logout request", malformed_logout_request },
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~
non_regression_tests.c:248:32: error: initializer element is not constant
non_regression_tests.c:248:32: note: (near initialization for 'tests[4].test')
make[3]: *** [Makefile:815: non_regression_tests.o] Error 1

#11 Updated by Benjamin Dauvergne 6 months ago

My bad I forgot the test qualifier, and with this one ?

diff --git tests/non_regression_tests.c tests/non_regression_tests.c
index d2993ecd..a6bd88fe 100644
--- tests/non_regression_tests.c
+++ tests/non_regression_tests.c
@@ -235,7 +235,11 @@ END_TEST

 struct {
        char *name;
-       void *function;
+#if (CHECK_MAJOR_VERSION > 0) || (CHECK_MINOR_VERSION > 12)
+       const TTest *test;
+#else
+       void *test;
+#endif
 } tests[] = {
        { "Googleapps error from coudot@ on 27-09-2010", test01_googleapps_27092010},
        { "Wrong assertionConsumer ordering on 08-10-2010", indexed_endpoints_20101008},
@@ -252,8 +256,7 @@ non_regression_suite()

        for (i = 0 ; i < G_N_ELEMENTS(tests); i++) {
                TCase *c = tcase_create(tests[i].name);
-               void *f = tests[i].function;
-               tcase_add_test(c, f);
+               tcase_add_test(c, tests[i].test);
                suite_add_tcase(s, c);
        }

#12 Updated by Jakub Hrozek 6 months ago

Benjamin Dauvergne a écrit :

My bad I forgot the test qualifier, and with this one ?

[...]

I'm getting a different error now:

make[3]: Entering directory '/home/jhrozek/devel/dist-git/lasso/lasso-2.6.0/tests'                                    
non_regression_tests.c:244:51: error: initializer element is not constant                                             
  244 |  { "Googleapps error from coudot@ on 27-09-2010", test01_googleapps_27092010},                                
      |                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~                                  
non_regression_tests.c:244:51: note: (near initialization for 'tests[0].test')                                        
non_regression_tests.c:245:54: error: initializer element is not constant                                             
  245 |  { "Wrong assertionConsumer ordering on 08-10-2010", indexed_endpoints_20101008},                             
      |                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~                               
non_regression_tests.c:245:54: note: (near initialization for 'tests[1].test')                                        
non_regression_tests.c:246:83: error: initializer element is not constant                                             
  246 |  { "Warning when parsing AttributeValue node containing unknown namespace nodes", remove_warning_when_parssing_unknown_SNIPPET_LIST_NODES_20111007 },
      |                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
non_regression_tests.c:246:83: note: (near initialization for 'tests[2].test')                                        
non_regression_tests.c:247:41: error: initializer element is not constant                                             
  247 |  { "Wrong endpoint index in artifacts", wrong_endpoint_index_in_artifacts },                                  
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                     
non_regression_tests.c:247:41: note: (near initialization for 'tests[3].test')                                        
non_regression_tests.c:248:32: error: initializer element is not constant                                             
  248 |  { "Malformed logout request", malformed_logout_request },                                                    
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~                                                       
non_regression_tests.c:248:32: note: (near initialization for 'tests[4].test')                        

#13 Updated by Benjamin Dauvergne 6 months ago

Ok the problem is the global declaration, and this one :

diff --git tests/non_regression_tests.c tests/non_regression_tests.c
index d2993ecd..d6ceffd3 100644
--- tests/non_regression_tests.c
+++ tests/non_regression_tests.c
@@ -233,27 +233,26 @@ START_TEST(malformed_logout_request)
 }
 END_TEST

-struct {
-       char *name;
-       void *function;
-} tests[] = {
-       { "Googleapps error from coudot@ on 27-09-2010", test01_googleapps_27092010},
-       { "Wrong assertionConsumer ordering on 08-10-2010", indexed_endpoints_20101008},
-       { "Warning when parsing AttributeValue node containing unknown namespace nodes", remove_warning_when_parssing_unknown_SNIPPET_LIST_NODES_20111007 },
-       { "Wrong endpoint index in artifacts", wrong_endpoint_index_in_artifacts },
-       { "Malformed logout request", malformed_logout_request },
-};
-
 Suite*
 non_regression_suite()
 {
+
+       struct {
+               char *name;
+               const void *test;
+       } tests[] = {
+               { "Googleapps error from coudot@ on 27-09-2010", test01_googleapps_27092010},
+               { "Wrong assertionConsumer ordering on 08-10-2010", indexed_endpoints_20101008},
+               { "Warning when parsing AttributeValue node containing unknown namespace nodes", remove_warning_when_parssing_unknown_SNIPPET_LIST_NODES_20111007 },
+               { "Wrong endpoint index in artifacts", wrong_endpoint_index_in_artifacts },
+               { "Malformed logout request", malformed_logout_request },
+       };
        Suite *s = suite_create("Non regression tests");
        unsigned int i = 0;

        for (i = 0 ; i < G_N_ELEMENTS(tests); i++) {
                TCase *c = tcase_create(tests[i].name);
-               void *f = tests[i].function;
-               tcase_add_test(c, f);
+               tcase_add_test(c, tests[i].test);
                suite_add_tcase(s, c);
        }

#14 Updated by Benjamin Dauvergne 6 months ago

Still here ?

#15 Updated by Jakub Hrozek 6 months ago

Benjamin Dauvergne a écrit :

Still here ?

I'm sorry for the delay. I was attending a conference for most of the week and forgot to reply here.
Nonetheless, I'm afraid even the last version of the patch does not help. I'm still getting:
non_regression_tests.c: In function 'non_regression_suite':

non_regression_tests.c:254:1: error: invalid use of void expression                                                   
  254 | +               tcase_add_test(c, tests[i].test);                                                             
      | ^                                                  
make[3]: *** [Makefile:815: non_regression_tests.o] Error 1                                                           
make[3]: Entering directory '/home/jhrozek/devel/dist-git/lasso/lasso-2.6.0/tests'                                    
  CC       non_regression_tests.o                

#16 Updated by Benjamin Dauvergne 5 months ago

I'm developping under Debian and that's my only target, check 0.13 is not available on this platform, I'm not sure I will be able to finish this patch without it.

#17 Updated by Benjamin Dauvergne 4 months ago

  • Status changed from En cours to Résolu (à déployer)
commit 6a0708ed5c663fc07f9df5079ec09c0eb35c2689
Author: Benjamin Dauvergne <bdauvergne@entrouvert.com>
Date:   Thu Mar 26 20:19:25 2020 +0100

    tests: fix compilation with check>0.12 (#39101)

#18 Updated by Benjamin Dauvergne 3 months ago

  • Target version set to 2.6.1

#19 Updated by Benjamin Dauvergne 3 months ago

  • Status changed from Résolu (à déployer) to Fermé

Also available in: Atom PDF