test_psa_constant_names: fix uses of C integer types

Some of the types may in principle be wider than `unsigned`, so use
`unsigned long` in printf.

Add support for signed types: a status is a signed value, and
preferentially printed in decimal.
diff --git a/tests/scripts/test_psa_constant_names.py b/tests/scripts/test_psa_constant_names.py
index 000dedc..d22652e 100755
--- a/tests/scripts/test_psa_constant_names.py
+++ b/tests/scripts/test_psa_constant_names.py
@@ -211,6 +211,12 @@
 
 def run_c(options, type, names):
     '''Generate and run a program to print out numerical values for names.'''
+    if type == 'status':
+        cast_to = 'long'
+        printf_format = '%ld'
+    else:
+        cast_to = 'unsigned long'
+        printf_format = '0x%08lx'
     c_name = None
     exe_name = None
     try:
@@ -230,7 +236,8 @@
 {
 ''')
         for name in names:
-            c_file.write('    printf("0x%08x\\n", {});\n'.format(name))
+            c_file.write('    printf("{}\\n", ({}) {});\n'
+                         .format(printf_format, cast_to, name))
         c_file.write('''    return 0;
 }
 ''')