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

(core dumped) test #33

Closed
wir19 opened this issue Dec 7, 2021 · 13 comments
Closed

(core dumped) test #33

wir19 opened this issue Dec 7, 2021 · 13 comments

Comments

@wir19
Copy link

wir19 commented Dec 7, 2021

./test_random 3 0100 80 02

test_random: bn.c:104: bignum_from_string: Assertion `(nbytes % (sizeof(uint32_t) * 2)) == 0 && "string length must be a multiple of (sizeof(DTYPE) * 2) characters"' failed.
Aborted (core dumped)
@kokke
Copy link
Owner

kokke commented Dec 15, 2021

Hi @wir19

Did you see the error message?

You are basically "using it wrong". test_random expects to be called in the following manner:

test_random <OP> <LHS> <RHS> <RESULT>

Where is the operand (enum), is the left-hand-side, is the right-hand-side and the expected results.

The function with the failing assertion is bignum_from_string which is used for testing only. It has a requirement that the input-strings are of even length and of a certain length (see the error message).
You are passing inputs that do uphold this requirement - thus the failed assertion.

#25 reports the very same issue.

@kokke kokke closed this as completed Dec 15, 2021
@xor256
Copy link

xor256 commented Dec 15, 2021

did You run this file and read example?
./test_random without parameter ;-)

second run this make clean all test

================================================================================
factorial(100) using Python = 1b30964ec395dc24069528d54bbda40d16e966ef9a70eb21b5b2943a321cdf10391745570cca9420c6ecb3b72ed2ee8b02ea2735c61a000000000000000000000000
factorial(100) using bignum = 1b30964ec395dc24069528d54bbda40d16e966ef9a70eb21b5b2943a321cdf10391745570cca9420c6ecb3b72ed2ee8b02ea2735c61a000000000000000000000000
================================================================================

Running test cases from error log (cases that failed during development).

0/0 tests passed.

@kokke
Copy link
Owner

kokke commented Dec 20, 2021

Hi @xor256

I don't understand what you are trying to say - can you rephrase/explain further?

@xor256
Copy link

xor256 commented Dec 20, 2021

Please run test_random without any parameters

You can read exactly this example. (You wrote "Did you see the error message?" ok, Did You read program help?)

./test_random 3 0100 80 02 is from help information when You run this program without parameter.

second trouble is 'make test' generate errors (look above)

@kokke
Copy link
Owner

kokke commented Dec 20, 2021

Maybe I'm misunderstanding you @xor256 , but you're not supposed to run test_random without any parameters.

The python script inserts relevant parameters in the Makefile - which leads to your second trouble:

make clean all test works fine on the machines I have available for testing. Here's a snippet of the output from one such machine:

$ make clean all test

================================================================================

Running "golden" tests (parsed using from_int):

[TEXT OMITTED]

152/152 tests successful.

================================================================================

Running hand-picked test cases:

3/3 tests successful.

================================================================================

Loading numbers from strings and from int.
Verifying comparison function.
Verifying to_string function.
Verifying increment + decrement functions.

Tests successful.

================================================================================
factorial(100) using Python = 1b30964ec395dc24069528d54bbda40d16e966ef9a70eb21b5b2943a321cdf10391745570cca9420c6ecb3b72ed2ee8b02ea2735c61a000000000000000000000000
factorial(100) using bignum = 1b30964ec395dc24069528d54bbda40d16e966ef9a70eb21b5b2943a321cdf10391745570cca9420c6ecb3b72ed2ee8b02ea2735c61a000000000000000000000000
================================================================================

Running test cases from error log (cases that failed during development).

1005/1005 tests passed.

================================================================================

Running 1000 random tests (parsed using from_string):

[TEXT OMITTED]

1000/1000 random tests passed.

================================================================================

So I guess it's a difference in our environments that is causing the trouble.

Using an Alpine docker-container

docker run --rm -it alpine

... this works for me:

apk add git musl-dev make gcc python2
cd /tmp
git clone https://github.com/kokke/tiny-bignum-c.git
cd tiny-bignum-c
make clean all test

@kokke
Copy link
Owner

kokke commented Dec 20, 2021

Could be an issue of Python2 vs Python3 - #29 alludes to that

@xor256
Copy link

xor256 commented Dec 20, 2021

Maybe I'm misunderstanding you @xor256 , but you're not supposed to run test_random without any parameters.
https://github.com/kokke/tiny-bignum-c/blob/master/tests/randomized.c
14 line
, 3 = div\n\nExample:\n %s 3 0100 80 02\n\n [divide 0x0100 by 0x80

kokke added a commit that referenced this issue Dec 20, 2021
@kokke
Copy link
Owner

kokke commented Dec 20, 2021

Maybe I'm misunderstanding you @xor256 , but you're not supposed to run test_random without any parameters.
https://github.com/kokke/tiny-bignum-c/blob/master/tests/randomized.c
14 line
, 3 = div\n\nExample:\n %s 3 0100 80 02\n\n [divide 0x0100 by 0x80

Does this f5586b4 address your objections ?

I did not expect the test-code to be scrutinized to this degree :) Thanks for helping me find the issue @xor256

@kokke
Copy link
Owner

kokke commented Dec 20, 2021

@xor256 I noticed that you responded with "thumbs-down" and "eyes" to my responses. Can you please put a few more words on that? Otherwise, I'm not sure what exactly you are objecting against :(

@xor256
Copy link

xor256 commented Dec 21, 2021

The thumbs down is unfortunately a certain attitude of yours. "it's all good why do you have a grudge, I'm not wrong" eyes always mean "I'm looking" or "looking".


[ OK ] 262144 >> 18 = 1
[ OK ] 524288 >> 19 = 1
[ OK ] 1048576 >> 20 = 1

152/152 tests successful.

================================================================================

Running hand-picked test cases:

3/3 tests successful.

================================================================================

Loading numbers from strings and from int.
Verifying comparison function.
Verifying to_string function.
Verifying increment + decrement functions.

Tests successful.

================================================================================
factorial(100) using Python = 1b30964ec395dc24069528d54bbda40d16e966ef9a70eb21b5b2943a321cdf10391745570cca9420c6ecb3b72ed2ee8b02ea2735c61a000000000000000000000000
factorial(100) using bignum = 1b30964ec395dc24069528d54bbda40d16e966ef9a70eb21b5b2943a321cdf10391745570cca9420c6ecb3b72ed2ee8b02ea2735c61a000000000000000000000000

Running test cases from error log (cases that failed during development).

0/0 tests passed.

================================================================================
File "./scripts/test_rand.py", line 123
expected = int(math.sqrt(oper1));
^
TabError: inconsistent use of tabs and spaces in indentation
make: *** [Makefile:31: test] Błąd 1

uname -a
Linux 5.11.22-100.fc32.x86_64 #1 SMP Wed May 19 18:58:25 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

fedora

python -v
....
Python 3.8.10 (default, May 4 2021, 00:00:00)
[GCC 10.2.1 20201125 (Red Hat 10.2.1-9)] on linux
...

@kokke
Copy link
Owner

kokke commented Dec 21, 2021

Could be an issue of Python2 vs Python3 - #29 alludes to that

Yup, that's the problem. The old scripts are not python3-compatible as is. Run them under python2 or consider upgrading them to python3.

The thumbs down is unfortunately a certain attitude of yours.

That did not help me understand what you are objecting to.

@xor256
Copy link

xor256 commented Dec 21, 2021

That did not help me understand what you are objecting to.
This is my suggestion to not write so aggressively. "Ah why didn't you read the documentation because you used the wrong input" but I just read the documentation. (The other thing is that you closed the thread)

meybe using Ruby not python? no python no problem ;-)

@kokke
Copy link
Owner

kokke commented Dec 21, 2021

This is my suggestion to not write so aggressively. "Ah why didn't you read the documentation because you used the wrong input" but I just read the documentation. (The other thing is that you closed the thread)

I had not understood that "make clean all test" failed, so I thought "why are you even running this stuff manually? just use the makefile as described". There was not a lot of description text to go by. Again: thank you for helping me understand the real issue here.

The "usage-text" describing how to call test_rand was valid only for the smallest word-size. The assertion-failure text says it much better, so I'll just keep that instead.

meybe using Ruby not python? no python no problem ;-)

Haha of course :P
The Python2 vs Python3 issue was not on my mind 4-5 years ago when I wrote this code. It should be updated to be Python3-compatible.

ParnikaGupta9 pushed a commit to Cypherock/x1_wallet_firmware that referenced this issue Aug 10, 2024
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

3 participants