📄 rf_testmain.c
字号:
/* * Copyright (c) 1996 Carnegie-Mellon University. * All rights reserved. * * Author: Mark Holland, Rachad Youssef, Jim Zelenka * * Permission to use, copy, modify and distribute this software and * its documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. * * Carnegie Mellon requests users of this software to return to * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 * * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. */#include "rf_threadstuff.h"#include "rf_types.h"#include <stdio.h>#include <stdlib.h>#include <signal.h>#include <unistd.h>#include <sys/file.h>#include "rf_raid.h"#include "rf_dag.h"#include "rf_threadid.h"#include "rf_randmacros.h"#include "rf_parityscan.h"#include "rf_etimer.h"#include "rf_script.h"#include "rf_mcpair.h"#include "rf_configure.h"#include "rf_stripelocks.h"#include "rf_general.h"#include "rf_utils.h"#include "rf_testcode.h"#include "rf_driver.h"#include "rf_cpuutil.h"#include "rf_map.h"#include "rf_dagutils.h"#include "rf_copyback.h"#include "rf_shutdown.h"#if RF_DEMO > 0#include "rf_demo.h"#endif /* RF_DEMO > 0 */#ifdef SIMULATE#include "rf_desc.h"#include "rf_owner.h"#include "rf_diskevent.h"#include "rf_diskthreads.h"#endif /* SIMULATE */static RF_Raid_t raidDescriptor; /* the primary RAID descriptor used at user level */static RF_Config_t globalConfig;static void usage(char *cname){ fprintf(stderr,"USAGE: %s config_file\n",cname);}#define CBUF_LEN 128int main(argc,argv) int argc; char **argv;{ char *cmdname = argv[0], cbuf[CBUF_LEN], *str; RF_ShutdownList_t *shutdownList; char *configname; int status, rc; if (argc != 2) { usage(cmdname); exit(1); } shutdownList = NULL; rf_BootRaidframe(); /* initialize some stuff */ /* step one: configure the system. */ configname = argv[1]; status = rf_MakeConfig(configname, &globalConfig); if (status) { printf("Unable to create configuration. Exiting.\n"); exit(1); } status = rf_Configure(&raidDescriptor, &globalConfig); free(globalConfig.layoutSpecific); /* we had to use malloc(), not Malloc() */ if (status) { RF_ERRORMSG("Unable to configure RAID device for the above reason(s). Exiting...\n"); exit(1); } globalRaidPtr = &raidDescriptor; /* debug only -- allows cleanup after ^C */ rf_TestcodeInit(&raidDescriptor);#if RF_DEMO > 0 if (rf_demoMode) { printf("Demo meter vertical screen offset [0-5]:"); gets(cbuf); rf_demoMeterVpos = atoi(cbuf); printf ("vertical meter offset %d \n", rf_demoMeterVpos); if (rf_demoMeterVpos < 0 || rf_demoMeterVpos > 5) rf_demoMeterVpos = 0; }#endif /* RF_DEMO > 0 */get_input:#ifndef SIMULATE fprintf(stderr,"[s] Single-Access Test\n"); fprintf(stderr,"[l] Loop Test\n"); fprintf(stderr,"[d] Degraded-Mode Read Test\n"); fprintf(stderr,"[r] Random R or W test\n"); fprintf(stderr,"[f] File Write-Read Test\n"); fprintf(stderr,"[R] Recon Test\n"); fprintf(stderr,"[w] Write array test\n");#endif /* !SIMULATE */ fprintf(stderr,"[S] Script Test\n"); fprintf(stderr,"[L] Layout Test\n"); fprintf(stderr,"\nPick a test: "); fflush(stderr); str = fgets(cbuf, CBUF_LEN, stdin); fprintf(stderr, "\n"); if (str == NULL) { fprintf(stderr, "Nothing to do, shutting down\n"); fflush(stderr); goto shutdown; } rf_test_running = 1;raidDescriptor.keep_acc_totals = 1; switch (*cbuf) {#ifndef SIMULATE case 's': SingleAccessTest(&raidDescriptor); break; case 'l': LoopTest(&raidDescriptor, &shutdownList); break; case 'd': DegradedModeReadTest(&raidDescriptor); break; case 'r': RandomReadTest(&raidDescriptor, &shutdownList); break; case 'f': FileWriteReadTest(&raidDescriptor); break; case 'R': ReconTest(&raidDescriptor, &shutdownList); break; case 'w': WriteArrayTest(&raidDescriptor, &shutdownList); break;#endif /* !SIMULATE */ case 'S': ScriptTest(&raidDescriptor, &shutdownList); break; case 'L': LayoutTest(&raidDescriptor); break; default: fprintf(stderr, "Huh?\n"); goto get_input; }shutdown: rf_test_running = 0; rf_ShutdownList(&shutdownList); rf_Shutdown(&raidDescriptor); rf_UnbootRaidframe(); /* XXX debugging, really */ return(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -