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 failure on i686 #1999

Closed
mtasaka opened this issue Aug 18, 2023 · 2 comments
Closed

Test failure on i686 #1999

mtasaka opened this issue Aug 18, 2023 · 2 comments
Assignees
Labels
bug Unexpected problem or unintended behavior
Milestone

Comments

@mtasaka
Copy link

mtasaka commented Aug 18, 2023

With weechat v4.0.3 as well as git head ( f89d4a6 ), there are some test failures on i686:

===================================================
1.

1: TEST(XferNetwork, ConvertIntegerToIpv4)
1: /builddir/build/BUILD/weechat-4.0.3/tests/unit/plugins/xfer/test-xfer-network.cpp:57: error: Failure in TEST(XferNetwork, ConvertIntegerToIpv4)
1:      expected <192.168.1.2>
1:      but was  <127.255.255.255>
1:      difference starts at position 1 at: <         127.255.255>

Perhaps this should be fixed by:

diff --git a/src/plugins/xfer/xfer-network.c b/src/plugins/xfer/xfer-network.c
index fffb7d869..584384948 100644
--- a/src/plugins/xfer/xfer-network.c
+++ b/src/plugins/xfer/xfer-network.c
@@ -57,17 +57,17 @@ char *
 xfer_network_convert_integer_to_ipv4 (const char *str_address)
 {
     char *error, result[128];
-    long number;
+    long long number;
 
     if (!str_address || !str_address[0])
         return NULL;
 
-    number = strtol (str_address, &error, 10);
-    if (!error || error[0] || (number <= 0))
+    number = strtoll (str_address, &error, 10);
+    if (!error || error[0] || (number <= 0) || (number > UINT32_MAX))
         return NULL;
 
     snprintf (result, sizeof (result),
-              "%ld.%ld.%ld.%ld",
+              "%lld.%lld.%lld.%lld",
               (number >> 24) & 0xFF,
               (number >> 16) & 0xFF,
               (number >> 8) & 0xFF,

===================================================
2.

1: /builddir/build/BUILD/weechat-4.0.3/tests/scripts/python/testapi.py:86:1: ERROR: [weechat_testapi.py] condition is false: weechat.string_parse_size('3g') == 3000000000

Perhaps this can be fixed by:

diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c
index 12cebcfcf..d0d241b36 100644
--- a/src/plugins/python/weechat-python-api.c
+++ b/src/plugins/python/weechat-python-api.c
@@ -80,6 +80,8 @@
     return PyLong_FromLong((long)__int)
 #define API_RETURN_LONG(__long)                                         \
     return PyLong_FromLong(__long)
+#define API_RETURN_LONGLONG(__longlong)                                 \
+    return PyLong_FromLongLong(__longlong)
 
 
 /*
@@ -374,14 +376,14 @@ API_FUNC(string_parse_size)
     char *size;
     unsigned long long value;
 
-    API_INIT_FUNC(1, "string_parse_size", API_RETURN_LONG(0));
+    API_INIT_FUNC(1, "string_parse_size", API_RETURN_LONGLONG(0));
     size = NULL;
     if (!PyArg_ParseTuple (args, "s", &size))
-        API_WRONG_ARGS(API_RETURN_LONG(0));
+        API_WRONG_ARGS(API_RETURN_LONGLONG(0));
 
     value = weechat_string_parse_size (size);
 
-    API_RETURN_LONG(value);
+    API_RETURN_LONGLONG(value);
 }
 
 API_FUNC(string_color_code_size)

Other language bindings may also need fixing. At least ruby also ruby needs fixing like:

diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c
index 4db4d3326..ec6ba2e65 100644
--- a/src/plugins/ruby/weechat-ruby-api.c
+++ b/src/plugins/ruby/weechat-ruby-api.c
@@ -77,6 +77,8 @@
     return INT2FIX (__int)
 #define API_RETURN_LONG(__long)                                         \
     return LONG2NUM (__long)
+#define API_RETURN_LONGLONG(__longlong)                                 \
+    return LL2NUM (__longlong)
 
 
 /*
@@ -454,9 +456,9 @@ weechat_ruby_api_string_parse_size (VALUE class, VALUE size)
     char *c_size;
     unsigned long long value;
 
-    API_INIT_FUNC(1, "string_parse_size", API_RETURN_LONG(0));
+    API_INIT_FUNC(1, "string_parse_size", API_RETURN_LONGLONG(0));
     if (NIL_P (size))
-        API_WRONG_ARGS(API_RETURN_LONG(0));
+        API_WRONG_ARGS(API_RETURN_LONGLONG(0));
 
     Check_Type (size, T_STRING);
 
@@ -464,7 +466,7 @@ weechat_ruby_api_string_parse_size (VALUE class, VALUE size)
 
     value = weechat_string_parse_size (c_size);
 
-    API_RETURN_LONG(value);
+    API_RETURN_LONGLONG(value);
 }
 
 static VALUE

I have not checked other language bindings.

===================================================
3.

1: ## test print_date_tags core buffer
1: =!= python: wrong arguments for function "prnt_date_tags" (script: weechat_testapi.py)
1: python: stdout/stderr (weechat_testapi.py): OverflowError: Python int too large to convert to C long
1: python: stdout/stderr (weechat_testapi.py): The above exception was the direct cause of the following exception:
1: python: stdout/stderr (weechat_testapi.py): Traceback (most recent call last):
1: python: stdout/stderr (weechat_testapi.py):   File "./tmp_weechat_test/testapi/weechat_testapi.py", line 488, in cmd_test_cb
1: python: stdout/stderr (weechat_testapi.py):     test_display()
1: python: stdout/stderr (weechat_testapi.py):   File "./tmp_weechat_test/testapi/weechat_testapi.py", line 289, in test_display
1: python: stdout/stderr (weechat_testapi.py):     weechat.prnt_date_tags('', 5680744830, 'tag1,tag2', '## test print_date_tags core buffer, year 2150')
1: python: stdout/stderr (weechat_testapi.py): SystemError: <built-in function prnt_date_tags> returned a result with an exception set
1: =!= python: error in function "cmd_test_cb"

I have not checked how to fix this.

The problem here is that python seems to raise exception, so further tests in TEST(Scripts, API) are not executed, so to execute other tests I have to comment out test functions written in testapi.py, then:

===================================================
4.

=!= python: wrong arguments for function "hook_timer" (script: weechat_testapi.py)
python: stdout/stderr (weechat_testapi.py): OverflowError: Python int too large to convert to C long
python: stdout/stderr (weechat_testapi.py): The above exception was the direct cause of the following exception:
python: stdout/stderr (weechat_testapi.py): Traceback (most recent call last):
python: stdout/stderr (weechat_testapi.py):   File "./tmp_weechat_test/testapi/weechat_testapi.py", line 502, in cmd_test_cb
python: stdout/stderr (weechat_testapi.py):     test_hooks()
python: stdout/stderr (weechat_testapi.py):   File "./tmp_weechat_test/testapi/weechat_testapi.py", line 363, in test_hooks
python: stdout/stderr (weechat_testapi.py):     hook_timer = weechat.hook_timer(5000111000, 0, 1, 'timer_cb', 'timer_cb_data')
python: stdout/stderr (weechat_testapi.py):                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
python: stdout/stderr (weechat_testapi.py): SystemError: <built-in function hook_timer> returned a result with an exception set
=!= python: error in function "cmd_test_cb"

===================================================
5.

=!= python: wrong arguments for function "prnt_date_tags" (script: weechat_testapi.py)
python: stdout/stderr (weechat_testapi.py): OverflowError: Python int too large to convert to C long
python: stdout/stderr (weechat_testapi.py): The above exception was the direct cause of the following exception:
python: stdout/stderr (weechat_testapi.py): Traceback (most recent call last):
python: stdout/stderr (weechat_testapi.py):   File "./tmp_weechat_test/testapi/weechat_testapi.py", line 503, in cmd_test_cb
python: stdout/stderr (weechat_testapi.py):     test_hdata()
python: stdout/stderr (weechat_testapi.py):   File "./tmp_weechat_test/testapi/weechat_testapi.py", line 428, in test_hdata
python: stdout/stderr (weechat_testapi.py):     weechat.prnt_date_tags(buffer2, 5680744830, 'tag1,tag2', 'prefix1\t## msg1')
python: stdout/stderr (weechat_testapi.py): SystemError: <built-in function prnt_date_tags> returned a result with an exception set
=!= python: error in function "cmd_test_cb"

Perhaps the same as 3.

Note that for 3, 4, 5 I only checked python bindings, for 2, also checked ruby but I have not checked other language bindings.

@mtasaka mtasaka added the bug Unexpected problem or unintended behavior label Aug 18, 2023
flashcode added a commit that referenced this issue Aug 18, 2023
flashcode added a commit that referenced this issue Aug 18, 2023
@flashcode
Copy link
Member

Thanks, all problems should be fixed on master and 4.0 branches.

@flashcode flashcode self-assigned this Aug 18, 2023
@flashcode flashcode added this to the 4.0.4 milestone Aug 18, 2023
@mtasaka
Copy link
Author

mtasaka commented Aug 19, 2023

Confirmed fixed, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants