Ejemplo n.º 1
0
static int proc_mode_help( const TE_NODE *node, int argc, const char **argv )
{
    OSH_ERROR status = OSH_ERR_NONE;
    int   i = 0;
    
    UNREFERENCED_PARAMETER(node);
    UNREFERENCED_PARAMETER(argc);
    UNREFERENCED_PARAMETER(argv);

    log_help(MODULE_NAME " is a tool for testing OpenSHMEM.\n");
    log_help("version %s\n", STR(VERSION));
    log_help("\n");
    log_help("Usage: " MODULE_NAME " <subcommand> [options] [args]\n");
    log_help("Type: \'" MODULE_NAME " <subcommand> --help\' for help on a specific subcommand.\n");
    log_help("Type: \'" MODULE_NAME " version\' to see the program version number.\n");
    log_help("\n");
    log_help("Available subcommands:\n");

    for ( i = 0; osh_modes[i].name != NULL; i++ ) {
        char tmp_buf[21];

        /* skip commands with prefix '--', they are special */
        if (osh_modes[i].name[0] != '-') {
            log_help("   %-20.20s\t%-s\n", display_opt(&osh_modes[i], tmp_buf, sizeof(tmp_buf)), osh_modes[i].note);
        }
    }

    log_help("\n");
    log_help("For additional information see README file, or Type \'" MODULE_NAME " <subcommand> --help\'.\n");

    return status;
}
Ejemplo n.º 2
0
int proc_tst_coll( const TE_NODE *node, int argc, const char **argv )
{
    OSH_ERROR status = OSH_ERR_NONE;
	const AOPT_OBJECT* self_opt_obj = NULL;

    UNREFERENCED_PARAMETER(argc);

    if (!node)
    {
        return OSH_ERR_FATAL;
    }

	/* Load supported option and create option objects */
	{
		int temp_argc = 0;

		temp_argc = argc;
		self_opt_obj = aopt_init(&temp_argc, (const char **)argv, self_opt_desc);
        if (!self_opt_obj)
        {
            status = OSH_ERR_FATAL;
        }
    }

	if (!status && self_opt_obj) 
    {
        /* Parse specific options */
    }

	if (status) 
    {
        /* Display help information */
	    const char* help_str = NULL;
	    char temp_buf[30];

		log_help("%s: %s\n", display_opt(node, temp_buf, sizeof(temp_buf)), node->note);
		log_help("\n");
		log_help("Valid arguments:\n");
		help_str = aopt_help(self_opt_desc);
	    if (help_str)
	    {
	        log_help("%s", help_str);
	        sys_free((void*)help_str);
		    log_help("\n");
	    }
	}

	/* Destroy option objects */
	aopt_exit((AOPT_OBJECT*)self_opt_obj);

    return status;
}
Ejemplo n.º 3
0
/*****************************************************************************
 * display a class
 *****************************************************************************/
static void
display_class(char *prefix, struct dpm_class *cls)
{
	int i;
	printk("%sClass: %s\n", prefix, cls->name);
	printk("%s\tentry count: %lld\n", prefix, cls->stats.count);
	printk("%s\t total time: %lld\n", prefix, cls->stats.total_time);
	printk("%s\t start time: %lld\n", prefix, cls->stats.start_time);
	printk("%s\t   end time: %lld\n", prefix, cls->stats.end_time);

	if (cls->opt)
		printk("%s\tThe selected opt for this class is %s\n",
		       prefix, cls->opt->name);
	else
		printk("%s\tThis class has no selected opt\n", prefix);
	printk("%s\tThis class has %d operating point%s:\n", prefix, cls->nops,
	       cls->nops == 1 ? "" : "s");
	for (i = 0; i < cls->nops; ++i)
		display_opt(prefix, cls->ops[i]);
}
Ejemplo n.º 4
0
static int __parse_opt( const TE_NODE *node, int argc, const char *argv[] )
{
    OSH_ERROR status = OSH_ERR_NONE;
	const AOPT_OBJECT* self_opt_obj = NULL;

	/* Load supported option and create option objects */
	{
		int temp_argc = 0;

		temp_argc = argc;
		self_opt_obj = aopt_init(&temp_argc, (const char **)argv, self_opt_desc);
	}

    /* Parse specific options */
	if (!status && self_opt_obj)
    {
        if ( !status && aopt_check(self_opt_obj, 'm') )
        {
            const char* optarg = aopt_value(self_opt_obj, 'm');
            if (optarg)
            {
                errno = 0;
                long value = sys_strtol(optarg, NULL, 0);
                if ( !errno && (value > 0) )
                {
                    __max_buffer_size = (int)value;
                }
                else
                {
                    status = OSH_ERR_BAD_ARGUMENT;
                }
            }
            else
            {
                status = OSH_ERR_BAD_ARGUMENT;
            }
        }

        if ( !status && aopt_check(self_opt_obj, 'c') )
        {
            const char* optarg = aopt_value(self_opt_obj, 'c');
            if (optarg)
            {
                errno = 0;
                long value = sys_strtol(optarg, NULL, 0);
                if ( !errno && (value > 0) )
                {
                    __cycle_count = (int)value;
                }
                else
                {
                    status = OSH_ERR_BAD_ARGUMENT;
                }
            }
            else
            {
                status = OSH_ERR_BAD_ARGUMENT;
            }
        }
	}

    if (status)
    {
        /* Display help information */
        const char* help_str = NULL;
        char temp_buf[30];

        log_help("%s: %s\n", display_opt(node, temp_buf, sizeof(temp_buf)), node->note);
        log_help("\n");
        log_help("Options:\n");
        help_str = aopt_help(self_opt_desc);
        if (help_str)
        {
            log_help("%s\n", help_str);
            sys_free((void*)help_str);
        }
    }

    aopt_exit((AOPT_OBJECT*)self_opt_obj);

    return status;
}
Ejemplo n.º 5
0
static int __parse_opt( const TE_NODE *node, int argc, const char *argv[] )
{
    OSH_ERROR status = OSH_ERR_NONE;
	const AOPT_OBJECT* self_opt_obj = NULL;

	/* Load supported option and create option objects */
	{
		int temp_argc = 0;

		temp_argc = argc;
		self_opt_obj = aopt_init(&temp_argc, (const char **)argv, self_opt_desc);
	}

    /* Parse specific options */
	if (!status && self_opt_obj) 
    {
        if ( !status && aopt_check(self_opt_obj, 'u') ) 
        {
            const char* optarg = aopt_value(self_opt_obj, 'u');
            if (optarg) 
            {
                errno = 0;
                if ( !sys_strcmp(optarg, "B") ) 
                {
                    __memory_unit_size = 1;
                    __memory_unit_size_str = "B";
                }
                else if ( !sys_strcmp(optarg, "KB") ) 
                {
                    __memory_unit_size = 1024;
                    __memory_unit_size_str = "KB";
                }
                else if ( !sys_strcmp(optarg, "MB") ) 
                {
                    __memory_unit_size = 1024 * 1024;
                    __memory_unit_size_str = "MB";
                }
                else if ( !sys_strcmp(optarg, "GB") ) 
                {
                    __memory_unit_size = 1024 * 1024 * 1024;
                    __memory_unit_size_str = "GB";
                }
                else
                {
                    __memory_unit_size = 1;
                    __memory_unit_size_str = "B";
                }
            }
            else 
            {
                status = OSH_ERR_BAD_ARGUMENT;
            }
        }
	}

    if (status) 
    {
        /* Display help information */
        const char* help_str = NULL;
        char temp_buf[30];

        log_help("%s: %s\n", display_opt(node, temp_buf, sizeof(temp_buf)), node->note);
        log_help("\n");
        log_help("Options:\n");
        help_str = aopt_help(self_opt_desc);
        if (help_str)
        {
            log_help("%s\n", help_str);
            sys_free((void*)help_str);
        }
    }

    aopt_exit((AOPT_OBJECT*)self_opt_obj);

    return status;
}