From 39a9c782b27ed9ea2faf342e9bff4309ba67c57f Mon Sep 17 00:00:00 2001 From: StevenWdV Date: Thu, 25 Nov 2021 15:27:06 +0100 Subject: Fix Python tests on unix --- wrappers/python/Makefile | 4 ++-- wrappers/python/discovery.py | 12 ++++++++---- wrappers/python/test_discovery.py | 0 3 files changed, 10 insertions(+), 6 deletions(-) mode change 100644 => 100755 wrappers/python/test_discovery.py (limited to 'wrappers/python') diff --git a/wrappers/python/Makefile b/wrappers/python/Makefile index 53d1375..162b043 100644 --- a/wrappers/python/Makefile +++ b/wrappers/python/Makefile @@ -1,7 +1,7 @@ .PHONY: compile test compile: - ./discovery.py + python3 -m discovery test: - ./test_discovery.py + python3 -m unittest test_discovery diff --git a/wrappers/python/discovery.py b/wrappers/python/discovery.py index 2a9dcbe..21118a9 100644 --- a/wrappers/python/discovery.py +++ b/wrappers/python/discovery.py @@ -1,9 +1,13 @@ -#!/usr/bin/env python3 - import platform from ctypes import * from enum import Enum +_lib_suffixes = { + "windows": ".dll", + "linux": ".so", + "darwin": ".dylib", +} + _arch = platform.machine().lower() _arch = \ { @@ -22,7 +26,7 @@ _arch = \ _os = platform.system().lower() -_lib = cdll.LoadLibrary(f"../../exports/{_os}/{_arch}/eduvpn_verify") +_lib = cdll.LoadLibrary(f"../../exports/{_os}/{_arch}/eduvpn_verify{_lib_suffixes[_os]}") class GoSlice(Structure): @@ -62,7 +66,7 @@ class VerifyError(Exception): VerifyErrorCode.ErrUnknownExpectedFileName: "unknown expected file name", VerifyErrorCode.ErrInvalidSignature: "invalid signature", VerifyErrorCode.ErrInvalidSignatureUnknownKey: "invalid signature (unknown key)", - VerifyErrorCode.ErrTooOld: "replay of previous signature (rollback)" + VerifyErrorCode.ErrTooOld: "replay of previous signature (rollback)", }[self.code] if self.code != VerifyErrorCode.Unknown else f"unknown verify error ({self.code_int})" diff --git a/wrappers/python/test_discovery.py b/wrappers/python/test_discovery.py old mode 100644 new mode 100755 -- cgit v1.2.3