Skip to content
New issue

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

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

Already on GitHub? # to your account

Test failures if certain architecture is not enabled #1689

Closed
relapids opened this issue Aug 16, 2022 · 1 comment
Closed

Test failures if certain architecture is not enabled #1689

relapids opened this issue Aug 16, 2022 · 1 comment

Comments

@relapids
Copy link
Contributor

Not sure if you consider this an issue or not, but I think some tests should perhaps be guarded by something like #ifdef UNICORN_HAS_ARM since test_ctl is included in the build by default (regardless of what you set for UNICORN_ARCH), but if for example you only have x86 enabled the tests won't work since they rely on having the arm architecture available.

Steps to reproduce:

PS E:\Dev\unicorn\build> cmake -S ..\repo\ -B . -G Ninja -D CMAKE_C_COMPILER=cl -D CMAKE_BUILD_TYPE=Debug -D UNICORN_ARCH="x86"
PS E:\Dev\unicorn\build> cmake --build .
PS E:\Dev\unicorn\build> cmake --build . --target test

Test output:

[0/1] Running tests...
Test project E:/Dev/unicorn/build
    Start 1: test_x86
1/3 Test #1: test_x86 .........................   Passed    1.65 sec
    Start 2: test_mem
2/3 Test #2: test_mem .........................   Passed    0.10 sec
    Start 3: test_ctl
3/3 Test #3: test_ctl .........................***Failed    0.06 sec

67% tests passed, 1 tests failed out of 3

Total Test time (real) =   1.81 sec

The following tests FAILED:
          3 - test_ctl (Failed)
PS E:\Dev\unicorn\build> .\test_ctl.exe
Test test_uc_ctl_mode...                        [ OK ]
Test test_uc_ctl_page_size...                   [ OK ]
Test test_uc_ctl_arch...                        [ OK ]
Test test_uc_ctl_time_out...                    [ OK ]
Test test_uc_ctl_exits...                       [ OK ]
Test test_uc_ctl_tb_cache...                    [ OK ]
Test test_uc_ctl_change_page_size...            [ FAILED ]
  test_ctl.c:183: Check __err == UC_ERR_OK... failed
    Invalid/unsupported architecture (UC_ERR_ARCH)
  test_ctl.c:184: Check __err == UC_ERR_OK... failed
    Invalid/unsupported architecture (UC_ERR_ARCH)
  Unhandled SEH exception... failed
    Exception code:    0xc0000005
    Exception address: 0x00007FFB19DC7036
  Access violation.
Test test_uc_ctl_arm_cpu...                     [ FAILED ]
  test_ctl.c:201: Check __err == UC_ERR_OK... failed
    Invalid/unsupported architecture (UC_ERR_ARCH)
  Unhandled SEH exception... failed
    Exception code:    0xc0000005
    Exception address: 0x00007FFB19DC742D
  Access violation.
Test test_uc_hook_cached_uaf...                 [ OK ]
FAILED: 2 of 9 unit tests have failed.

The same thing applies in reverse to the various mem/ctl tests which rely on x86 architecture, but that's probably a much more common use case (i.e. having x86 enabled vs having x86 disabled) so I'm only pointing out the arm specific tests here, since for one of my use cases I only need x86 and I disable the rest to speed up my CI builds and reduce binary sizes (and I like to run the tests on my dependencies to ensure everything is behaving correctly). That being said fixing the inverse would also be nice to allow running the automatically included tests cleanly if you only enable e.g. aarch64.

Relevant tests (for an x86-only build) which should maybe be guarded are:
test_uc_ctl_change_page_size
test_uc_ctl_arm_cpu

Though, I can understand if this is considered "by design"/"won't fix". Wanted to get your thoughts before I proposed any changes.

@aquynh
Copy link
Member

aquynh commented Aug 16, 2022 via email

wtdcode added a commit that referenced this issue Aug 31, 2022
Disable ARM-specific tests when ARM is unavailable. (#1689)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants