Home | History | Annotate | Download | only in diskomizer
      1 /*
      2  * CDDL HEADER START
      3  *
      4  * The contents of this file are subject to the terms of the
      5  * Common Development and Distribution License (the "License").
      6  * You may not use this file except in compliance with the License.
      7  *
      8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
      9  * or http://www.opensolaris.org/os/licensing.
     10  * See the License for the specific language governing permissions
     11  * and limitations under the License.
     12  *
     13  * When distributing Covered Code, include this CDDL HEADER in each
     14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     15  * If applicable, add the following below this CDDL HEADER, with the
     16  * fields enclosed by brackets "[]" replaced with your own identifying
     17  * information: Portions Copyright [yyyy] [name of copyright owner]
     18  *
     19  * CDDL HEADER END
     20  */
     21 
     22 #pragma ident	"@(#)arg_test.c	1.9	09/05/26 SMI"
     23 
     24 /*
     25  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
     26  * Use is subject to license terms.
     27  */
     28 
     29 /*
     30  * Short test program to test the argument processing in args.o for
     31  * arbitrary options.
     32  */
     33 
     34 #include <stdio.h>
     35 #include "args.h"
     36 #include "time.h"
     37 
     38 void *usage_tracking_handle;
     39 
     40 const int this_proc = 0;
     41 void *
     42 alloc_mem(long a, long b)
     43 {
     44 	return (calloc(a, b));
     45 }
     46 
     47 void
     48 nop(void)
     49 {
     50 }
     51 
     52 int
     53 main(int argc, char **argv)
     54 {
     55 	short s;
     56 	int n;
     57 	char *str;
     58 	const struct option_ops *opts;
     59 	const char *path;
     60 
     61 	path = set_diskomizer_path();
     62 
     63 	/* do_args implicitly calls opts_init() */
     64 	if (0 == do_args(argc, argv, pprintf, path)) {
     65 		(void) fprintf(stderr, "do_args failed\n");
     66 		exit(1);
     67 	}
     68 
     69 	if (option_ops.opt_short("SHORT_TEST", &s)) {
     70 		(void) fprintf(stderr, "SHORT_TEST = %hd\n", s);
     71 	}
     72 	if (option_ops.opt_int("NPROCS", &n)) {
     73 		(void) fprintf(stderr, "NPROCS = %d\n", n);
     74 	}
     75 	opts = opts_init();
     76 	if (opts->opt_str("DEVICE", &str) && str != NULL) {
     77 		(void) fprintf(stderr, "DEVICE =%s\n", str);
     78 	}
     79 	opts_fini();
     80 	opts_fini();
     81 	/* This should return not found */
     82 	if (option_ops.opt_short("SHORT_TEST", &s)) {
     83 		(void) fprintf(stderr,
     84 		    "Argg SHORT_TEST = %hd after opts_fini\n", s);
     85 	}
     86 	exit(0);
     87 	return (0);
     88 }
     89