Home | History | Annotate | Download | only in old
      1 /*
      2  * Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved.
      3  *
      4  * This program is free software; you can redistribute it and/or
      5  * modify it under the terms of the GNU General Public License as
      6  * published by the Free Software Foundation; either version 2 of
      7  * the License, or (at your option) any later version.
      8  *
      9  * This program is distributed in the hope that it would be useful,
     10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12  * GNU General Public License for more details.
     13  *
     14  * You should have received a copy of the GNU General Public License
     15  * along with this program; if not, write the Free Software Foundation,
     16  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     17  *
     18  * Author:
     19  * Alexey Kodanev <alexey.kodanev (at) oracle.com>
     20  *
     21  * These functions help to load and unload kernel modules in the tests.
     22  *
     23  * tst_module_load function already includes tst_module_exists function,
     24  * which is checking the following possible module's locations:
     25  *
     26  * 1. Current working directory
     27  *
     28  * 2. LTP installation path (using env LTPROOT, which is usually /opt/ltp)
     29  *
     30  * 3. If tmp directory created, it'll look at the test start working directory
     31  *
     32  */
     33 
     34 #ifndef TST_MODULE
     35 #define TST_MODULE
     36 
     37 /*
     38  * Check module existence.
     39  *
     40  * @mod_name: module's file name.
     41  * @mod_path: if it is not NULL, then tst_module_exists places the found
     42  * module's path into the location pointed to by *mod_path. It must be freed
     43  * with free() when it is no longer needed.
     44  *
     45  * In case of failure, test'll call cleanup_fn and exit with TCONF return value.
     46  */
     47 void tst_module_exist(void (cleanup_fn)(void), const char *mod_name,
     48 	char **mod_path);
     49 
     50 /*
     51  * Load a module using insmod program.
     52  *
     53  * @mod_name: module's file name.
     54  * @argv: an array of pointers to null-terminated strings that represent the
     55  * additional parameters to the module. The array of pointers  must be
     56  * terminated by a NULL pointer. If argv points to NULL, it will be ignored.
     57  *
     58  * In case of insmod failure, test will call cleanup_fn and exit with TBROK
     59  * return value.
     60  */
     61 void tst_module_load(void (cleanup_fn)(void),
     62 	const char *mod_name, char *const argv[]);
     63 
     64 /*
     65  * Unload a module using rmmod program. In case of failure, test will call
     66  * cleanup_fn and exit with TBROK return value.
     67  *
     68  * @mod_name: can be module name or module's file name.
     69  */
     70 void tst_module_unload(void (cleanup_fn)(void), const char *mod_name);
     71 
     72 #endif /* TST_MODULE */
     73