From 3ac36b8644bf6c250de1c80010cecb16a68b5ad6 Mon Sep 17 00:00:00 2001
From: Mathieu Faverge <mathieu.faverge@inria.fr>
Date: Thu, 14 May 2020 16:42:00 +0200
Subject: [PATCH] Factorize the strings declarations in spm testings

---
 tests/spm_compare.c              |  8 +++++---
 tests/spm_dof_expand_tests.c     |  4 ----
 tests/spm_dof_matvec_tests.c     |  4 ----
 tests/spm_dof_norm_tests.c       | 19 ++++++-------------
 tests/spm_matvec_tests.c         |  5 -----
 tests/spm_norm_tests.c           | 12 ++----------
 tests/spm_scatter_gather_tests.c |  1 -
 tests/spm_tests.h                |  8 +++++---
 8 files changed, 18 insertions(+), 43 deletions(-)

diff --git a/tests/spm_compare.c b/tests/spm_compare.c
index 6ef899ef..d16adad3 100644
--- a/tests/spm_compare.c
+++ b/tests/spm_compare.c
@@ -13,9 +13,11 @@
  **/
 #include "spm_tests.h"
 
-char* fltnames[] = { "Pattern", "", "Float", "Double", "Complex32", "Complex64" };
-char* fmtnames[] = { "CSC", "CSR", "IJV" };
-char* mtxnames[] = { "General", "Symmetric", "Hermitian" };
+const char* fltnames[]   = { "Pattern", "", "Float", "Double", "Complex32", "Complex64" };
+const char* fmtnames[]   = { "CSC", "CSR", "IJV" };
+const char* mtxnames[]   = { "General", "Symmetric", "Hermitian" };
+const char *dofname[]    = { "None", "Constant", "Variadic" };
+const char* transnames[] = { "NoTrans", "Trans", "ConjTrans" };
 
 static inline int
 spmCompareFloatArray( spm_int_t n,
diff --git a/tests/spm_dof_expand_tests.c b/tests/spm_dof_expand_tests.c
index 61f600ed..d49612e0 100644
--- a/tests/spm_dof_expand_tests.c
+++ b/tests/spm_dof_expand_tests.c
@@ -34,10 +34,6 @@
         printf("SUCCESS\n");                    \
     }
 
-char* fltnames[] = { "Pattern", "", "Float", "Double", "Complex32", "Complex64" };
-char* fmtnames[] = { "CSC", "CSR", "IJV" };
-char* mtxnames[] = { "General", "Symmetric", "Hermitian" };
-
 int main (int argc, char **argv)
 {
     spmatrix_t    original, *spm;
diff --git a/tests/spm_dof_matvec_tests.c b/tests/spm_dof_matvec_tests.c
index b0bde26c..5841ce04 100644
--- a/tests/spm_dof_matvec_tests.c
+++ b/tests/spm_dof_matvec_tests.c
@@ -32,10 +32,6 @@
         printf("SUCCESS\n");                    \
     }
 
-char* fltnames[] = { "Pattern", "", "Float", "Double", "Complex32", "Complex64" };
-char* fmtnames[] = { "CSC", "CSR", "IJV" };
-char* mtxnames[] = { "General", "Symmetric", "Hermitian" };
-
 int main (int argc, char **argv)
 {
     spmatrix_t    original, *spm;
diff --git a/tests/spm_dof_norm_tests.c b/tests/spm_dof_norm_tests.c
index e0303723..8383fb32 100644
--- a/tests/spm_dof_norm_tests.c
+++ b/tests/spm_dof_norm_tests.c
@@ -22,11 +22,6 @@
 #include <time.h>
 #include <spm_tests.h>
 
-int z_spm_norm_check( const spmatrix_t *spm );
-int c_spm_norm_check( const spmatrix_t *spm );
-int d_spm_norm_check( const spmatrix_t *spm );
-int s_spm_norm_check( const spmatrix_t *spm );
-
 #define PRINT_RES(_ret_)                        \
     if(_ret_) {                                 \
         printf("FAILED(%d)\n", _ret_);          \
@@ -36,10 +31,6 @@ int s_spm_norm_check( const spmatrix_t *spm );
         printf("SUCCESS\n");                    \
     }
 
-char* fltnames[] = { "Pattern", "", "Float", "Double", "Complex32", "Complex64" };
-char* fmtnames[] = { "CSC", "CSR", "IJV" };
-char* mtxnames[] = { "General", "Symmetric", "Hermitian" };
-
 int main (int argc, char **argv)
 {
     spmatrix_t    original, *spm;
@@ -108,10 +99,12 @@ int main (int argc, char **argv)
                         continue;
                     }
 
-                    printf(" Case: %d / %s / %s / %d / %s\n",
-                           i, fltnames[spm->flttype],
-                           fmtnames[spm->fmttype], baseval,
-                           mtxnames[mtxtype - SpmGeneral] );
+                    printf( " Case: %s / %s / %s / %d / %s\n",
+                            fltnames[spm->flttype],
+                            dofname[i+1],
+                            mtxnames[mtxtype - SpmGeneral],
+                            baseval,
+                            fmtnames[spm->fmttype] );
 
                     switch( spm->flttype ){
                     case SpmComplex64:
diff --git a/tests/spm_matvec_tests.c b/tests/spm_matvec_tests.c
index 61740c69..84108b9b 100644
--- a/tests/spm_matvec_tests.c
+++ b/tests/spm_matvec_tests.c
@@ -31,11 +31,6 @@
         printf("SUCCESS\n");                    \
     }
 
-char* fltnames[] = { "Pattern", "", "Float", "Double", "Complex32", "Complex64" };
-char* transnames[] = { "NoTrans", "Trans", "ConjTrans" };
-char* mtxnames[] = { "General", "Symmetric", "Hermitian" };
-char* fmtnames[] = { "CSC", "CSR", "IJV" };
-
 int main (int argc, char **argv)
 {
     spmatrix_t    spm;
diff --git a/tests/spm_norm_tests.c b/tests/spm_norm_tests.c
index 4e49a15a..41523904 100644
--- a/tests/spm_norm_tests.c
+++ b/tests/spm_norm_tests.c
@@ -22,11 +22,6 @@
 #include <time.h>
 #include <spm_tests.h>
 
-int z_spm_norm_check( const spmatrix_t *spm );
-int c_spm_norm_check( const spmatrix_t *spm );
-int d_spm_norm_check( const spmatrix_t *spm );
-int s_spm_norm_check( const spmatrix_t *spm );
-
 #define PRINT_RES(_ret_)                        \
     if(_ret_) {                                 \
         printf("FAILED(%d)\n", _ret_);          \
@@ -36,10 +31,6 @@ int s_spm_norm_check( const spmatrix_t *spm );
         printf("SUCCESS\n");                    \
     }
 
-char* fltnames[] = { "Pattern", "", "Float", "Double", "Complex32", "Complex64" };
-char* fmtnames[] = { "CSC", "CSR", "IJV" };
-char* mtxnames[] = { "General", "Symmetric", "Hermitian" };
-
 int main (int argc, char **argv)
 {
     spmatrix_t    spm;
@@ -101,7 +92,8 @@ int main (int argc, char **argv)
 
                 printf(" Case: %s / %s / %d / %s\n",
                        fltnames[spm.flttype],
-                       fmtnames[spm.fmttype], baseval,
+                       fmtnames[spm.fmttype],
+                       baseval,
                        mtxnames[mtxtype - SpmGeneral] );
 
                 switch( spm.flttype ){
diff --git a/tests/spm_scatter_gather_tests.c b/tests/spm_scatter_gather_tests.c
index f9c4ec40..0678923a 100644
--- a/tests/spm_scatter_gather_tests.c
+++ b/tests/spm_scatter_gather_tests.c
@@ -75,7 +75,6 @@ spmdist_check_scatter_gather( spmatrix_t    *original,
                               int            root,
                               int            clustnum )
 {
-    const char *dofname[]  = { "None", "Constant", "Variadic" };
     const char *distname[] = { "Round-Robin", "Continuous "};
     spmatrix_t *spms = NULL;
     spmatrix_t *spmg = NULL;
diff --git a/tests/spm_tests.h b/tests/spm_tests.h
index c7610f53..011be821 100644
--- a/tests/spm_tests.h
+++ b/tests/spm_tests.h
@@ -20,9 +20,11 @@
 #include <stdio.h>
 #include <spm.h>
 
-extern char* fltnames[];
-extern char* fmtnames[];
-extern char* mtxnames[];
+extern const char* fltnames[];
+extern const char* fmtnames[];
+extern const char* mtxnames[];
+extern const char *dofname[];
+extern const char* transnames[];
 
 void spmGetOptions( int argc, char **argv,
                     spm_driver_t *driver, char **filename );
-- 
GitLab