[ofw] [patch] osmtest - creating and deleting the inventory file
Irena Gannon
irena at mellanox.co.il
Sun Sep 12 03:06:38 PDT 2010
The patch creates an inventory file, if it did not exist before, when creating the DB and deletes this file if it was created during the run.
Index: D:/Windows/MLNX_VPI_2_1_2/ulp/opensm/user/osmtest/osmtest.c
===================================================================
--- D:/Windows/MLNX_VPI_2_1_2/ulp/opensm/user/osmtest/osmtest.c (revision 6412)
+++ D:/Windows/MLNX_VPI_2_1_2/ulp/opensm/user/osmtest/osmtest.c (revision 6455)
@@ -7089,11 +7089,28 @@
fh = fopen(p_osmt->opt.file_name, "r");
if (fh == NULL) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0130: "
- "Unable to open inventory file (%s)\n",
- p_osmt->opt.file_name);
- status = IB_ERROR;
- goto Exit;
+ OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "Inventory file (%s) doesn't exist. "
+ "The file will be created.\n", p_osmt->opt.file_name);
+
+ /*
+ * Creating an inventory file with all nodes, ports and paths
+ */
+ status = osmtest_create_inventory_file(p_osmt);
+ if (status != IB_SUCCESS) {
+ OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0139: "
+ "Inventory file create failed (%s)\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+
+ fh = fopen(p_osmt->opt.file_name, "r");
+ if (fh == NULL) {
+ OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0130: "
+ "Unable to open inventory file (%s)\n",
+ p_osmt->opt.file_name);
+ status = IB_ERROR;
+ goto Exit;
+ }
}
/*
Index: D:/Windows/MLNX_VPI_2_1_2/ulp/opensm/user/osmtest/main.c
===================================================================
--- D:/Windows/MLNX_VPI_2_1_2/ulp/opensm/user/osmtest/main.c (revision 6412)
+++ D:/Windows/MLNX_VPI_2_1_2/ulp/opensm/user/osmtest/main.c (revision 6455)
@@ -291,7 +291,7 @@
#else
const char *const short_option = "f:l:m:M:d:g:s:t:i:pcvVh";
#endif
-
+ FILE* inventoryExists = NULL;
/*
* In the array below, the 2nd parameter specified the number
* of arguments as follows:
@@ -344,6 +344,9 @@
opt.flow = OSMT_FLOW_ALL; /* run all validation tests */
strcpy(flow_name, "All Validations");
strcpy(opt.file_name, "osmtest.dat");
+ inventoryExists = (fopen(opt.file_name,"r"));
+ if (inventoryExists)
+ fclose(inventoryExists);
printf("\nCommand Line Arguments\n");
do {
@@ -597,7 +600,7 @@
if (cl_hton64(guid) == cl_hton64(INVALID_GUID)) {
print_all_guids(&osm_test);
complib_exit();
- return (status);
+ goto Exit;
}
/*
@@ -615,7 +618,7 @@
*/
status = osmtest_bind(&osm_test, max_lid, guid);
if (status != IB_SUCCESS)
- exit(status);
+ goto Exit;
status = osmtest_run(&osm_test);
if (status != IB_SUCCESS) {
@@ -628,5 +631,18 @@
complib_exit();
Exit:
+ if (!inventoryExists) //The file did not exist in the begging of the run
+ {
+ inventoryExists = (fopen(opt.file_name,"r"));
+ if (inventoryExists) //If the file exists after the run - we created it
+ {
+ fclose(inventoryExists);
+ if (system("del osmtest.dat"))
+ {
+ printf("Warning: Inventory file cleanup failed\n");
+ }
+ }
+ }
+
return (status);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20100912/642c10df/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: osmtest_inventory.patch
Type: application/octet-stream
Size: 2958 bytes
Desc: osmtest_inventory.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20100912/642c10df/attachment.obj>
More information about the ofw
mailing list