ltp-ddt nand_perf_ubifs_w_cpuload

NAND_M_PERF_UBIFS_CPU_LOAD source 'common.sh';/opt/ltp/runltp -f ddt/nand_perf_ubifs -s "NAND_S_PERF_UBIFS " -P $PLATFORM -c 8
 
runltp -c
 
in runltp:
 
do  case $arg in
    c)       
            NUM_PROCS=$(($OPTARG))
            if   [ "$NUM_PROCS" -eq 0 ]; then
                # User Did not Define the Value ,or, User Defined Zero,
                # hence, prevent from creating infinite processes
                NUM_PROCS=1
            fi
            $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 &
            GENLOAD=1 ;;
 
 
genload --cpu $NUM_PROCS >/dev/null 2>&1 &
 
-c, --cpu n           spawn n procs spinning on sqrt() "
genload in ltp-ddt-backup-servergit oolsgenload
 
->main
else if (strcmp(arg, "--cpu") == 0 || strcmp(arg, "-c") == 0) {
            do_cpu = 1;
            assert_arg("--cpu");
            do_cpu_forks = atoll_b(arg);
 
/* Hog CPU option.  */
    if (do_cpu) {
        out(stdout, "dispatching %lli hogcpu forks ", do_cpu_forks);

        switch (pid = fork()) {
        case 0:    /* child */
            if (do_dryrun)
                exit(0);
            exit(hogcpu(do_cpu_forks));
        case -1:    /* error */
            err(stderr, "hogcpu dispatcher fork failed ");
            exit(1);
        default:    /* parent */
            children++;
            dbg(stdout, "--> hogcpu dispatcher forked (%i) ", pid);
        }
    }
 
in hogcpu
 
for (i = 0; forks == 0 || i < forks; i++) {
        switch (pid = fork()) {
        case 0:    /* child */
            alarm(timeout);

            /* Use a backoff sleep to ensure we get good fork throughput.  */
            usleep(backoff);

            while (1)
                d = sqrt(rand());

            /* This case never falls through; alarm signal can cause exit.  */
        case -1:    /* error */
            if (ignore) {
                ++retval;
                wrn(stderr,
                    "hogcpu worker fork failed, continuing ");
                usleep(retry);
                continue;
            }

            err(stderr, "hogcpu worker fork failed ");
            return 1;
        default:    /* parent */
            dbg(stdout, "--> hogcpu worker forked (%i) ", pid);
        }
    }
 
 
 
 
 
 
 
原文地址:https://www.cnblogs.com/idyllcheung/p/10950864.html