Modify test_psa_compliance.py for psa-crypto repo

Signed-off-by: David Horstmann <david.horstmann@arm.com>
diff --git a/tests/scripts/test_psa_compliance.py b/tests/scripts/test_psa_compliance.py
index 92db417..a1a0260 100755
--- a/tests/scripts/test_psa_compliance.py
+++ b/tests/scripts/test_psa_compliance.py
@@ -28,6 +28,9 @@
 import subprocess
 import sys
 
+import scripts_path
+from mbedtls_dev import build_tree
+
 # PSA Compliance tests we expect to fail due to known defects in Mbed TLS (or the test suite)
 # The test numbers correspond to the numbers used by the console output of the test suite.
 # Test number 2xx corresponds to the files in the folder
@@ -53,8 +56,11 @@
 def main():
     mbedtls_dir = os.getcwd()
 
-    if not os.path.exists('library/libmbedcrypto.a'):
-        subprocess.check_call(['make', '-C', 'library', 'libmbedcrypto.a'])
+    is_psa_crypto = build_tree.looks_like_psa_crypto_root(mbedtls_dir) #type: bool
+
+    if not is_psa_crypto:
+        if not os.path.exists('library/libmbedcrypto.a'):
+            subprocess.check_call(['make', '-C', 'library', 'libmbedcrypto.a'])
 
     psa_arch_tests_dir = 'psa-arch-tests'
     os.makedirs(psa_arch_tests_dir, exist_ok=True)
@@ -74,6 +80,15 @@
         os.mkdir(build_dir)
         os.chdir(build_dir)
 
+        if is_psa_crypto:
+            psa_crypto_lib_filename = \
+                'mbedtls_out_of_source_build/core/libpsacrypto.a'
+        else:
+            psa_crypto_lib_filename = 'library/libmbedcrypto.a'
+
+        extra_includes = (';{}/drivers/builtin/include'.format(mbedtls_dir)
+                          if is_psa_crypto else '')
+
         #pylint: disable=bad-continuation
         subprocess.check_call([
             'cmake', '..',
@@ -81,8 +96,9 @@
                      '-DTARGET=tgt_dev_apis_stdc',
                      '-DTOOLCHAIN=HOST_GCC',
                      '-DSUITE=CRYPTO',
-                     '-DPSA_CRYPTO_LIB_FILENAME={}/library/libmbedcrypto.a'.format(mbedtls_dir),
-                     '-DPSA_INCLUDE_PATHS={}/include'.format(mbedtls_dir)
+                     '-DPSA_CRYPTO_LIB_FILENAME={}/{}'.format(mbedtls_dir,
+                                                              psa_crypto_lib_filename),
+                     ('-DPSA_INCLUDE_PATHS={}/include' + extra_includes).format(mbedtls_dir)
         ])
         subprocess.check_call(['cmake', '--build', '.'])