LCOV - code coverage report
Current view: top level - app/test-mldev - ml_test.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 1 0.0 %
Date: 2024-12-01 18:57:19 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright (c) 2022 Marvell.
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef ML_TEST_H
       6                 :            : #define ML_TEST_H
       7                 :            : 
       8                 :            : #include <stdio.h>
       9                 :            : #include <stdlib.h>
      10                 :            : #include <string.h>
      11                 :            : #include <sys/queue.h>
      12                 :            : 
      13                 :            : #include <rte_common.h>
      14                 :            : 
      15                 :            : #include "ml_options.h"
      16                 :            : 
      17                 :            : #define ML_TEST_MAX_POOL_SIZE 256
      18                 :            : 
      19                 :            : enum ml_test_result {
      20                 :            :         ML_TEST_SUCCESS,
      21                 :            :         ML_TEST_FAILED,
      22                 :            :         ML_TEST_UNSUPPORTED,
      23                 :            : };
      24                 :            : 
      25                 :            : struct ml_test;
      26                 :            : 
      27                 :            : typedef bool (*ml_test_capability_check_t)(struct ml_options *opt);
      28                 :            : typedef int (*ml_test_options_check_t)(struct ml_options *opt);
      29                 :            : typedef void (*ml_test_options_dump_t)(struct ml_options *opt);
      30                 :            : typedef int (*ml_test_setup_t)(struct ml_test *test, struct ml_options *opt);
      31                 :            : typedef void (*ml_test_destroy_t)(struct ml_test *test, struct ml_options *opt);
      32                 :            : typedef int (*ml_test_driver_t)(struct ml_test *test, struct ml_options *opt);
      33                 :            : typedef int (*ml_test_result_t)(struct ml_test *test, struct ml_options *opt);
      34                 :            : 
      35                 :            : struct ml_test_ops {
      36                 :            :         ml_test_capability_check_t cap_check;
      37                 :            :         ml_test_options_check_t opt_check;
      38                 :            :         ml_test_options_dump_t opt_dump;
      39                 :            :         ml_test_setup_t test_setup;
      40                 :            :         ml_test_destroy_t test_destroy;
      41                 :            :         ml_test_driver_t test_driver;
      42                 :            :         ml_test_result_t test_result;
      43                 :            : };
      44                 :            : 
      45                 :            : struct ml_test {
      46                 :            :         const char *name;
      47                 :            :         void *test_priv;
      48                 :            :         struct ml_test_ops ops;
      49                 :            : };
      50                 :            : 
      51                 :            : struct ml_test_entry {
      52                 :            :         struct ml_test test;
      53                 :            : 
      54                 :            :         STAILQ_ENTRY(ml_test_entry) next;
      55                 :            : };
      56                 :            : 
      57                 :            : static inline void *
      58                 :            : ml_test_priv(struct ml_test *test)
      59                 :            : {
      60                 :          0 :         return test->test_priv;
      61                 :            : }
      62                 :            : 
      63                 :            : struct ml_test *ml_test_get(const char *name);
      64                 :            : void ml_test_register(struct ml_test_entry *test);
      65                 :            : void ml_test_dump_names(void (*f)(const char *));
      66                 :            : 
      67                 :            : #define ML_TEST_REGISTER(nm) \
      68                 :            :         static struct ml_test_entry _ml_test_entry_##nm; \
      69                 :            :         RTE_INIT(ml_test_##nm) \
      70                 :            :         { \
      71                 :            :                 _ml_test_entry_##nm.test.name = RTE_STR(nm); \
      72                 :            :                 memcpy(&_ml_test_entry_##nm.test.ops, &nm, sizeof(struct ml_test_ops)); \
      73                 :            :                 ml_test_register(&_ml_test_entry_##nm); \
      74                 :            :         }
      75                 :            : 
      76                 :            : #endif /* ML_TEST_H */

Generated by: LCOV version 1.14