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

ci: github actions CI for Windows x86 and x64 #1554

Merged
merged 2 commits into from
Sep 20, 2023

Conversation

res0nance
Copy link
Contributor

Add CI with testing

  • Does this PR change the input/output behaviour of a cryptographic algorithm (i.e., does it change known answer test values)? (If so, a version bump will be required from x.y.z to x.(y+1).0.)
  • Does this PR change the list of algorithms available -- either adding, removing, or renaming? Does this PR otherwise change an API? (If so, PRs in oqs-provider, OQS-OpenSSL, OQS-BoringSSL, and OQS-OpenSSH will also need to be ready for review and merge by the time this is merged.)

@dstebila dstebila merged commit 007219c into open-quantum-safe:main Sep 20, 2023
20 checks passed
@res0nance res0nance deleted the win-intel branch September 21, 2023 14:50
@qnfm
Copy link
Contributor

qnfm commented Sep 21, 2023

@res0nance
As mention here, my problem remains even the CI pass.
If I build this commit according to windows.yml

cmake -B build --toolchain .CMake\toolchain_windows_amd64.cmake
cmake --build build
python -m pytest --numprocesses=auto -vv --maxfail=10 --ignore=tests/test_code_conventions.py --junitxml=build\test-results\pytest\test-results.xml

The log is:

kem_name = 'FrodoKEM-1344-AES'

    @helpers.filtered_test
    @pytest.mark.parametrize('kem_name', helpers.available_kems_by_name())
    def test_alg_info_kem(kem_name):
        if not(helpers.is_kem_enabled_by_name(kem_name)): pytest.skip('Not enabled')
        # get the algorithm info from liboqs
>       output = helpers.run_subprocess([helpers.path_to_executable('dump_alg_info')])

tests\test_alg_info.py:15:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

program_name = 'dump_alg_info'

    def path_to_executable(program_name):
        path = "."
        if sys.platform.startswith("win"):
            if 'APPVEYOR_BUILD_FOLDER' not in os.environ: os.environ['APPVEYOR_BUILD_FOLDER'] = "."
            path = os.path.join(path, os.environ['APPVEYOR_BUILD_FOLDER'])
        path = os.path.join(path, get_current_build_dir_name(), "tests")
        if sys.platform.startswith("win"):
            if 'GITHUB_ACTIONS' in os.environ:
                path = os.path.join(path, "Debug")
        for executable in [
            os.path.join(path, program_name),
            os.path.join(path, program_name + ".EXE"),
            os.path.join(path, program_name + ".exe")]:
                if os.path.isfile(executable):
                    return executable
>       assert False, "Unable to find executable file {}".format(program_name)
E       AssertionError: Unable to find executable file dump_alg_info

tests\helpers.py:156: AssertionError

And if I remove the GITHUB_ACTION line like this:

if sys.platform.startswith("win"):
        path = os.path.join(path, "Debug")

It outputs:

tests\helpers.py:45: AssertionError
----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------
. > .\.\build\tests\Debug\dump_alg_info.EXE
. > grep -r -l Classic-McEliece-6688128 docs/algorithms/kem
'grep' is not recognized as an internal or external command,
operable program or batch file.

After I add grep to path, the test_alg_info_* pass

set PATH=%PATH%;C:\Program Files\Git\usr\bin

the test_alg_info_* pass but test_distbuild.py failed

____________________________________________________________________________ test_kem[Classic-McEliece-8192128f] ____________________________________________________________________________
[gw1] win32 -- Python 3.11.3 C:\Users\Alan\AppData\Local\Programs\Python\Python311\python.exe

kem_name = 'Classic-McEliece-8192128f'

    @helpers.filtered_test
    @pytest.mark.parametrize('kem_name', helpers.available_kems_by_name())
    @helpers.test_requires_build_options("OQS_DIST_BUILD")
    @helpers.test_requires_qemu(platform.machine(), MINCPU)
    def test_kem(kem_name):
        if not(helpers.is_kem_enabled_by_name(kem_name)):
            pytest.skip('Not enabled')

        arch = platform.machine()
        if "AMD64" in arch:
            arch = "x86_64"
>       helpers.run_subprocess(["qemu-"+arch+"-static", "-cpu", MINCPU,
                                helpers.path_to_executable('test_kem'), kem_name])

tests\test_distbuild.py:29:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

command = ['qemu-x86_64-static', '-cpu', 'max', '.\\.\\build\\tests\\Debug\\test_kem.EXE', 'Classic-McEliece-8192128f'], working_dir = '.'
env = {'ALLUSERSPROFILE': 'C:\\ProgramData', 'ANDROID_HOME': 'C:\\Program Files\\Android\\Android Studio', 'APPDATA': 'C:\\Users\\Alan\\AppData\\Roaming', 'APPVEYOR_BUILD_FOLDER': '.', ...}
expected_returncode = 0, input = None, ignore_returncode = False

    def run_subprocess(command, working_dir='.', env=None, expected_returncode=0, input=None, ignore_returncode=False):
        """
        Helper function to run a shell command and report success/failure
        depending on the exit status of the shell command.
        """
        env_ = os.environ.copy()
        if env is not None:
            env_.update(env)
        env = env_

        # Note we need to capture stdout/stderr from the subprocess,
        # then print it, which pytest will then capture and
        # buffer appropriately
        print(working_dir + " > " + " ".join(command))
        shell_= False
        if sys.platform.startswith("win"):
            shell_ = True
        result = subprocess.run(
                command,
                input=input,
                stdout=subprocess.PIPE,
                stderr=subprocess.STDOUT,
                cwd=working_dir,
                env=env,
                shell=shell_
            )

        if not(ignore_returncode) and (result.returncode != expected_returncode):
            print(result.stdout.decode('utf-8'))
>           assert False, "Got unexpected return code {}".format(result.returncode)
E           AssertionError: Got unexpected return code 1

tests\helpers.py:45: AssertionError
----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------
. > qemu-x86_64-static -cpu max .\.\build\tests\Debug\test_kem.EXE Classic-McEliece-8192128f
'qemu-x86_64-static' is not recognized as an internal or external command,
operable program or batch file.

------------------------------------------------------ generated xml file: D:\dev\c\liboqs\build\test-results\pytest\test-results.xml -------------------------------------------------------
================================================================================== short test summary info ==================================================================================
FAILED tests/test_distbuild.py::test_kem[Classic-McEliece-348864] - AssertionError: Got unexpected return code 1
FAILED tests/test_distbuild.py::test_kem[Classic-McEliece-348864f] - AssertionError: Got unexpected return code 1
FAILED tests/test_distbuild.py::test_kem[Classic-McEliece-460896] - AssertionError: Got unexpected return code 1
FAILED tests/test_distbuild.py::test_kem[Classic-McEliece-460896f] - AssertionError: Got unexpected return code 1
FAILED tests/test_distbuild.py::test_kem[Classic-McEliece-6688128] - AssertionError: Got unexpected return code 1
FAILED tests/test_distbuild.py::test_kem[Classic-McEliece-6688128f] - AssertionError: Got unexpected return code 1
FAILED tests/test_distbuild.py::test_kem[Classic-McEliece-6960119] - AssertionError: Got unexpected return code 1
FAILED tests/test_distbuild.py::test_kem[Classic-McEliece-6960119f] - AssertionError: Got unexpected return code 1
FAILED tests/test_distbuild.py::test_kem[Classic-McEliece-8192128] - AssertionError: Got unexpected return code 1
FAILED tests/test_distbuild.py::test_kem[Classic-McEliece-8192128f] - AssertionError: Got unexpected return code 1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 10 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! xdist.dsession.Interrupted: stopping after 10 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
======================================================================== 10 failed, 57 passed, 24 skipped in 29.97s =========================================================================

In that case, I have a few questions:

Qestion 1
I applied #1554 change back to my branch. But wider thing happened: The github action didn't run the test_distbuild.py (idk why)
Question 2
I do not have the qemu installed on my local windows, and the windows cmd prompt return code of subprocess,run() is 1. But the function test_requires_qemu in 'test_distbuild.py' set ignore_returncode=True. I think the expected behavior here should be NOT ignore the code and throw exception then set no_qemu=True.

After I modified the code as followed:

return pytest.mark.skipif(no_qemu,
                reason='Test requires qemu-{}-static -cpu {}'.format(platform, mincpu))

All the tests passed

@baentsch
Copy link
Member

@qnfm Can you confirm your problem described above is gone since #1557 landed? If not, can you please create a new issue documenting what's still not OK after #1554 and #1557 landed? It's not good to discuss on a merged PR....

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

Successfully merging this pull request may close these issues.

4 participants