diff --git a/testing/chameleon_ztesting.c b/testing/chameleon_ztesting.c index 52f552a7c69d947b4fb25a336603bb8f4cebbc84..27e2ad9e4b607408c499d1dbaafd1f03107630fd 100644 --- a/testing/chameleon_ztesting.c +++ b/testing/chameleon_ztesting.c @@ -22,7 +22,8 @@ * @author Lucas Nesi * @author Matthieu Kuhn * @author Lionel Eyraud-Dubois - * @date 2025-01-15 + * @author Matteo Marcos + * @date 2025-03-24 * @precisions normal z -> c d s * */ @@ -111,10 +112,11 @@ parameter_t parameters[] = { { "trans", "Value of the trans parameter ('ConjTrans', 'Trans', 'NoTrans')", -11, PARAM_OPTION | PARAM_INPUT | PARAM_OUTPUT, 2, 9, TestTrans, {0}, NULL, pread_trans, sprint_trans }, { "transA", "Value of the transA parameter ('ConjTrans', 'Trans', 'NoTrans')", -12, PARAM_OPTION | PARAM_INPUT | PARAM_OUTPUT, 2, 9, TestTrans, {0}, NULL, pread_trans, sprint_trans }, { "transB", "Value of the transB parameter ('ConjTrans', 'Trans', 'NoTrans')", -13, PARAM_OPTION | PARAM_INPUT | PARAM_OUTPUT, 2, 9, TestTrans, {0}, NULL, pread_trans, sprint_trans }, - { "uplo", "Value of the uplo parameter ('Upper', 'Lower', 'UpperLower')", -14, PARAM_OPTION | PARAM_INPUT | PARAM_OUTPUT, 2, 7, TestUplo, {0}, NULL, pread_uplo, sprint_uplo }, - { "diag", "Value of the diag parameter ('NonUnit', 'Unit')", -15, PARAM_OPTION | PARAM_INPUT | PARAM_OUTPUT, 2, 7, TestDiag, {0}, NULL, pread_diag, sprint_diag }, - { "side", "Value of the side parameter ('Left', 'Right')", -16, PARAM_OPTION | PARAM_INPUT | PARAM_OUTPUT, 2, 5, TestSide, {0}, NULL, pread_side, sprint_side }, - { "norm", "Value of the norm parameter ('One', 'Frobenius', 'Inf', 'Max')", -17, PARAM_OPTION | PARAM_INPUT | PARAM_OUTPUT, 2, 4, TestNormtype, {0}, NULL, pread_norm, sprint_norm }, + { "uplo", "Value of the uplo parameter ('Upper', 'Lower', 'UpperLower')", -14, PARAM_OPTION | PARAM_INPUT | PARAM_OUTPUT, 2, 7, TestUplo, {0}, NULL, pread_uplo, sprint_uplo }, + { "diag", "Value of the diag parameter ('NonUnit', 'Unit')", -15, PARAM_OPTION | PARAM_INPUT | PARAM_OUTPUT, 2, 7, TestDiag, {0}, NULL, pread_diag, sprint_diag }, + { "side", "Value of the side parameter ('Left', 'Right')", -16, PARAM_OPTION | PARAM_INPUT | PARAM_OUTPUT, 2, 5, TestSide, {0}, NULL, pread_side, sprint_side }, + { "norm", "Value of the norm parameter ('One', 'Frobenius', 'Inf', 'Max')", -17, PARAM_OPTION | PARAM_INPUT | PARAM_OUTPUT, 2, 4, TestNormtype, {0}, NULL, pread_norm, sprint_norm }, + { "dir", "Value of the dir parameter ('Forward', 'Backward')", -18, PARAM_OPTION | PARAM_INPUT | PARAM_OUTPUT, 2, 7, TestDir, {0}, NULL, pread_dir, sprint_dir }, { NULL, "Operation specific scalar", 0, PARAM_OPTION, 0, 0, 0, {0}, NULL, NULL, NULL }, { "alpha", "Value of the scalar alpha", 'x', PARAM_OPTION | PARAM_INPUT | PARAM_OUTPUT, 2, 13, TestValComplex64, {0}, NULL, pread_complex64, sprint_complex64 }, diff --git a/testing/run_list.c b/testing/run_list.c index a6900e88e637536a16d1cb65664195f9f62a2d07..a8fefce450a464200d804f20123f401b79bcf364 100644 --- a/testing/run_list.c +++ b/testing/run_list.c @@ -13,7 +13,8 @@ * @author Mathieu Faverge * @author Philippe Swartvagher * @author Alycia Lisito - * @date 2024-02-18 + * @author Matteo Marcos + * @date 2025-03-24 * */ #include "testings.h" @@ -442,6 +443,32 @@ run_arg_get_side( run_arg_list_t *arglist, const char *name, cham_side_t defval return rval.side; } +/** + * @brief Searches for a cham_dir_t value by its name. + * + * @param[inout] arglist + * The list of arguments. + * On exit, if the argument was not in the list, the default value is + * stored in it. + * + * @param[in] name + * The name of the argument to look for. + * + * @param[in] defval + * The default value if no argument is found with this name. This value + * is added to the list if not found. + * + * @retval The value of the argument _name_. + */ +cham_dir_t +run_arg_get_dir( run_arg_list_t *arglist, const char *name, cham_dir_t defval ) +{ + val_t val, rval; + val.dir = defval; + rval = run_arg_get( arglist, name, val ); + return rval.dir; +} + /** * @brief Searches for a cham_job_t value by its name. * diff --git a/testing/testings.h b/testing/testings.h index d341be66bbe4fe56964aea72fa2d4eeb4d8ec042..25283a6630e2c673cecda41380bbc32544b6085f 100644 --- a/testing/testings.h +++ b/testing/testings.h @@ -14,7 +14,8 @@ * @author Alycia Lisito * @author Florent Pruvost * @author Lionel Eyraud-Dubois - * @date 2024-03-21 + * @author Matteo Marcos + * @date 2025-03-24 * */ #ifndef _testings_h_ @@ -45,6 +46,7 @@ typedef enum valtype_ { TestUplo, TestDiag, TestSide, + TestDir, TestJob, TestNormtype, TestString, @@ -59,6 +61,7 @@ union val_u { cham_uplo_t uplo; cham_diag_t diag; cham_side_t side; + cham_dir_t dir; cham_job_t job; cham_normtype_t ntype; CHAMELEON_Complex64_t zval; @@ -168,6 +171,7 @@ val_t pread_trans ( const char *str ); val_t pread_uplo ( const char *str ); val_t pread_diag ( const char *str ); val_t pread_side ( const char *str ); +val_t pread_dir ( const char *str ); val_t pread_job ( const char *str ); val_t pread_norm ( const char *str ); val_t pread_string ( const char *str ); @@ -185,6 +189,7 @@ char *sprint_trans ( val_t val, int human, int nbchar, char *str_in ); char *sprint_uplo ( val_t val, int human, int nbchar, char *str_in ); char *sprint_diag ( val_t val, int human, int nbchar, char *str_in ); char *sprint_side ( val_t val, int human, int nbchar, char *str_in ); +char *sprint_dir ( val_t val, int human, int nbchar, char *str_in ); char *sprint_job ( val_t val, int human, int nbchar, char *str_in ); char *sprint_norm ( val_t val, int human, int nbchar, char *str_in ); char *sprint_string ( val_t val, int human, int nbchar, char *str_in ); @@ -209,6 +214,7 @@ cham_trans_t run_arg_get_trans ( run_arg_list_t *arglist, const char cham_uplo_t run_arg_get_uplo ( run_arg_list_t *arglist, const char *name, cham_uplo_t defval ); cham_diag_t run_arg_get_diag ( run_arg_list_t *arglist, const char *name, cham_diag_t defval ); cham_side_t run_arg_get_side ( run_arg_list_t *arglist, const char *name, cham_side_t defval ); +cham_dir_t run_arg_get_dir ( run_arg_list_t *arglist, const char *name, cham_dir_t defval ); cham_job_t run_arg_get_job ( run_arg_list_t *arglist, const char *name, cham_job_t defval ); cham_normtype_t run_arg_get_ntype ( run_arg_list_t *arglist, const char *name, cham_normtype_t defval ); int run_arg_get_ib ( run_arg_list_t *arglist ); diff --git a/testing/values.c b/testing/values.c index 3f3ed0bbca83a1a82c6b5e660cf3705e2251d7c2..36e42b256569d32f5a3b9740cc784553b6527345 100644 --- a/testing/values.c +++ b/testing/values.c @@ -14,7 +14,8 @@ * @author Alycia Lisito * @author Florent Pruvost * @author Philippe Swartvagher - * @date 2024-08-28 + * @author Matteo Marcos + * @date 2025-03-24 * */ #include "testings.h" @@ -266,6 +267,41 @@ val_t pread_side( const char *str ) return val; } + +/** + * @brief Convert the input string to a cham_dir_t + * @param[in] str + * The input string + * @return The cham_dir_t read. + */ +val_t pread_dir( const char *str ) +{ + val_t val; + val.dir = ChamDirForward; + + /* Keep in sync with help documentation in testing/{chameleon,vendor}_ztesting.c */ + if ( ( strcasecmp( "ChamDirForward", str ) == 0 ) || + ( strcasecmp( "Forward", str ) == 0 ) ) + { + val.dir = ChamDirForward; + } + else if ( ( strcasecmp( "ChamDirBackward", str ) == 0 ) || + ( strcasecmp( "Backward", str ) == 0 ) ) + { + val.dir = ChamDirBackward; + } + else { + int v = atoi( str ); + if ( ( v == ChamDirForward ) || ( v == ( ChamDirForward - ChamDirBackward ) ) ) { + val.dir = ChamDirForward; + } + else { + val.dir = ChamDirBackward; + } + } + return val; +} + /** * @brief Convert the input string to a cham_job_t * @param[in] str @@ -582,6 +618,25 @@ char *sprint_side( val_t val, int human, int nbchar, char *str_in ) return str_in+rc; } +/** + * @brief Convert the input string to a cham_dir_t + * @param[in] str + * The input string + * @return The cham_dir_t read. + */ +char *sprint_dir( val_t val, int human, int nbchar, char *str_in ) +{ + int rc; + if ( human ) { + rc = sprintf( str_in, " %-*s", nbchar, + (val.dir == ChamDirForward) ? "Forward" : "Backward" ); + } + else { + rc = sprintf( str_in, ";%d", val.dir ); + } + return str_in+rc; +} + /** * @brief Convert the input string to a cham_job_t * @param[in] str