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

AssertionError in test_uuid on NetBSD: Expected UUID version 1, but got version 4 #124228

Closed
furkanonder opened this issue Sep 18, 2024 · 2 comments
Labels
3.12 bugs and security fixes 3.13 bugs and security fixes 3.14 new features, bugs and security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@furkanonder
Copy link
Contributor

furkanonder commented Sep 18, 2024

Bug report

Bug description:

home# ./python -m test test_uuid
Using random seed: 2311813199
0:00:00 load avg: 0.11 Run 1 test sequentially in a single process
0:00:00 load avg: 0.11 [1/1] test_uuid
test test_uuid failed -- Traceback (most recent call last):
  File "/home/blue/cpython/Lib/test/test_uuid.py", line 496, in test_uuid1
    equal(u.version, 1)
    ~~~~~^^^^^^^^^^^^^^
AssertionError: 4 != 1

test_uuid failed (1 failure)

== Tests result: FAILURE ==

1 test failed:
    test_uuid

Total duration: 1.1 sec
Total tests: run=72 failures=1 skipped=13
Total test files: run=1/1 failed=1
Result: FAILURE

CPython versions tested on:

CPython main branch

Operating systems tested on:

Other

Linked PRs

@furkanonder furkanonder added type-bug An unexpected behavior, bug, or error tests Tests in the Lib/test dir 3.12 bugs and security fixes 3.13 bugs and security fixes 3.14 new features, bugs and security fixes labels Sep 18, 2024
@furkanonder
Copy link
Contributor Author

In NetBSD the py_uuid_generate_time_safe function generates a uuid using the uuid_create and uuid_enc_be functions. The uuid version generated is 4.

An example to reproduce the situation;

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <uuid.h>

int main() {
    uuid_t *uuid;
    unsigned char encoded_uuid[16];

    uuid = malloc(sizeof(struct uuid));
    if (!uuid) {
        fprintf(stderr, "Memory allocation failed\n");
        return 1;
    }

    uuid_create(uuid, NULL);
    uuid_enc_be(encoded_uuid, uuid);

    printf("Converted UUID: ");
    for (int i = 0; i < 16; i++) {
        printf("%02x", encoded_uuid[i]);
        if ((i == 3 || i == 5 || i == 7 || i == 9) && i < 15) {
            printf("-");
        }
    }

    printf("\n");
    free(uuid);

    return 0;
}
home$ gcc uuid_example.c -o uuid_example
home$ ./uuid_example
Converted UUID: 18bea948-0a56-4b61-9973-10ce1a098203
home$ ./uuid_example
Converted UUID: 1b2f696c-942e-490d-bfa6-d49246de6ad2
home$ ./uuid_example
Converted UUID: f9aa5345-9ac2-4528-8817-bf5b8a60ba4d

vstinner pushed a commit that referenced this issue Sep 23, 2024
Fix UUID configuration in configure files for NetBSD compatibility.
@vstinner
Copy link
Member

Fixed by 2e8c769.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and security fixes 3.13 bugs and security fixes 3.14 new features, bugs and security fixes tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants