Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test failures on architectures where char is unsigned #30

Closed
s-fritsch opened this issue Nov 3, 2016 · 4 comments
Closed

Test failures on architectures where char is unsigned #30

s-fritsch opened this issue Nov 3, 2016 · 4 comments
Assignees

Comments

@s-fritsch
Copy link

I have packaged the mapcode utility for Debian linux and there are unit test failures on architectures where char is unsigned (like arm and powerpc):

    Mapcode format tests
    *** ERROR *** compareWithMapcodeFormatUtf8("###################") returns -298 (-297 expected)
    *** ERROR *** "ttat.tt    " : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** compareWithMapcodeFormatUtf8("ttat-tt tt.tt") returns -288 (-289 expected)
    *** ERROR *** compareWithMapcodeFormatUtf8("ttat tt.tt") returns -288 (-289 expected)
    *** ERROR *** "XXAX.XXXX" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "2A22.2222" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "22A2.2222" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "MAP.CODE" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "XAXX.XXXX" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "XXXA.XXXX" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "XXXAX.XXXX" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "XXXXA.XXXX" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "nld XXXX.XXXXA" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "nld XXXX.ALA" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "nld XXXX.LAXA" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "nld XXXX.LLLLA" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "nld XXXX.A2e" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "nld XXXX.2e2e" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "nld XXXX.2222u" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "222A.2222" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "222A2.2222" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "ttt 2222A.2222" : myParseMapcodeString=-199, compareWithMapcodeFormatUtf8=0
    *** ERROR *** compareWithMapcodeFormatUtf8("ttt 2222A.2222") returns -199 (-289 expected)
    *** ERROR *** "2222.2AAA" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "A222.2AAA" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "xx-xx xx.x#x" : myParseMapcodeString=-199, compareWithMapcodeFormatUtf8=0
    *** ERROR *** compareWithMapcodeFormatUtf8("xx-xx xx.x#x") returns -199 (-297 expected)
    *** ERROR *** "xx# xx.xx" : myParseMapcodeString=-199, compareWithMapcodeFormatUtf8=0
    *** ERROR *** compareWithMapcodeFormatUtf8("xx# xx.xx") returns -199 (-297 expected)
    *** ERROR *** "xx-xx #xx.xx" : myParseMapcodeString=-199, compareWithMapcodeFormatUtf8=0
    *** ERROR *** compareWithMapcodeFormatUtf8("xx-xx #xx.xx") returns -199 (-297 expected)
    *** ERROR *** "xx-xx xx.xx-xx#xx" : myParseMapcodeString=-199, compareWithMapcodeFormatUtf8=0
    *** ERROR *** compareWithMapcodeFormatUtf8("xx-xx xx.xx-xx#xx") returns -199 (-297 expected)
    *** ERROR *** "DDDa.DDD" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "DDDDE.xxxx" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** compareWithMapcodeFormatUtf8("DDDDDA   xx.xx") returns -298 (-289 expected)
    *** ERROR *** "DD.DDDDA      " : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** compareWithMapcodeFormatUtf8("DD.DD-A") returns 0 (-293 expected)
    *** ERROR *** myParseMapcodeString("DD.DD-A")=-98, expected 0
    *** ERROR *** compareWithMapcodeFormatUtf8("DD.DD-xA") returns 0 (-293 expected)
    *** ERROR *** myParseMapcodeString("DD.DD-xA")=-98, expected 0
    *** ERROR *** compareWithMapcodeFormatUtf8("DD.DD-xxxE") returns 0 (-293 expected)
    *** ERROR *** myParseMapcodeString("DD.DD-xxxE")=-98, expected 0
    *** ERROR *** compareWithMapcodeFormatUtf8("DD.DD-xxxxxu") returns 0 (-293 expected)
    *** ERROR *** myParseMapcodeString("DD.DD-xxxxxu")=-98, expected 0
    *** ERROR *** "ta.xx     " : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "DD-DD AA.33  " : myParseMapcodeString=-199, compareWithMapcodeFormatUtf8=0
    *** ERROR *** compareWithMapcodeFormatUtf8("DD-DD AA.33  ") returns -199 (-289 expected)
    *** ERROR *** "DD-DD A3A.XX " : myParseMapcodeString=-199, compareWithMapcodeFormatUtf8=0
    *** ERROR *** compareWithMapcodeFormatUtf8("DD-DD A3A.XX ") returns -199 (-289 expected)
    *** ERROR *** "DD-DD A33A.XX" : myParseMapcodeString=-199, compareWithMapcodeFormatUtf8=0
    *** ERROR *** compareWithMapcodeFormatUtf8("DD-DD A33A.XX") returns -199 (-289 expected)
    *** ERROR *** "tta.ttt    " : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "ttaa.ttt   " : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "XXXX.AXXX" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "nld XXXX.AXX" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "nld XXXX.XAXX" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "nld XXXX.AXXA" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "2222.A22" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "2222.A222" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** "2222.2A22" : myParseMapcodeString=-289, compareWithMapcodeFormatUtf8=0
    *** ERROR *** compareWithMapcodeFormatUtf8("NLD
49.YV") returns -298 (-297 expected)
49.YV") returns -298 (-297 expected)atUtf8("NLD
    *** ERROR *** compareWithMapcodeFormatUtf8("NLD
                                               49.YV") returns -298 (-297 expected)
    *** ERROR *** compareWithMapcodeFormatUtf8("NL49.YV") returns -298 (-297 expected)
    *** ERROR *** compareWithMapcodeFormatUtf8("NLD49.YV") returns -298 (-297 expected)
    *** ERROR *** 93 of 288 myParseMapcodeString() calls succeeded (expected 89)
    *** ERROR *** invalid mapcode "NLD XXX.#XX" decodes without error

You can use -funsigned-char with gcc to simulate the effect on x86.

You probably should add something like this in testEnvironment() in the unit test, to get this information in the test output:

    char t = (char)(-1);

    if ((int)t == -1)
          printf("char is signed\n");
    else
          printf("char is unsigned\n");
@rijnb
Copy link
Member

rijnb commented Nov 4, 2016

The issue is confirmed and we will look into it. Thanks!

@rijnb rijnb self-assigned this Nov 4, 2016
@rijnb
Copy link
Member

rijnb commented Nov 4, 2016

I've added some remarks in README.md and added a test in unittest.c.
@s-fritsch Can you verify if it possible to add a compiler switch on ARM/PowerPC to change the default behavior of compilers to using signed char instead of unsigned char?

@s-fritsch
Copy link
Author

With gcc, adding -fsigned-char fixes the issue. For our purpose, adding add_compile_options("-fsigned-char") to CMakeLists.txt works. If you are interested, the CMakeLists.txt I am using at the moment is here: http://sources.debian.net/src/mapcode/2.5.1-2/CMakeLists.txt/ It has some more changes, like adding math and pthread libraries.

But I don't know cmake enough to make it check if the used compiler supports -fsigned-char.

@rijnb
Copy link
Member

rijnb commented Nov 5, 2016

@s-fritsch We fixed the signed/unsigned char issue, so the compiler setting is irrelevant now.
Thanks for sharing the CMakeLists.txt improvements. I've incorporated them. Check out (non-release, work-in-progress) branch dev-2.5.2.

@rijnb rijnb closed this as completed Nov 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants