Example #1
0
void xml_formatter::
output_symbol(ostream & out,
	symbol_entry const * symb, size_t lo, size_t hi, bool is_module)
{
	ostringstream str;
	// pointless reference to is_module, remove insane compiler warning
	size_t indx = is_module ? 0 : 1;

	// output symbol's summary data for each profile class
	bool got_samples = false;

	for (size_t p = lo; p <= hi; ++p) {
		got_samples |= xml_support->output_summary_data(str,
		    symb->sample.counts, p);
	}

	if (!got_samples)
		return;

	if (cverb << vxml)
		out << "<!-- symbol_ref=" << symbol_names.name(symb->name) <<
			" -->" << endl;

	out << open_element(SYMBOL, true);

	string const name = symbol_names.name(symb->name);
	assert(name.size() > 0);
	
	string const image = get_image_name(symb->image_name,
		image_name_storage::int_filename, extra_found_images);
	string const qname = image + ":" + name;

	indx = xml_get_symbol_index(qname);

	out << init_attr(ID_REF, indx);

	if (need_details) {
		ostringstream details;
		symbol_details_t & sd = symbol_details[indx];
		size_t const detail_lo = sd.index;

		string detail_str = output_symbol_details(symb, sd.index, lo, hi);

		if (detail_str.size() > 0) {
			if (sd.id < 0)
				sd.id = indx;
			details << detail_str;
		}

		if (sd.index > detail_lo) {
			sd.details = sd.details + details.str();
			out << init_attr(DETAIL_LO, detail_lo);
			out << init_attr(DETAIL_HI, sd.index-1);
		}
	}
	out << close_element(NONE, true);
	// output summary
	out << str.str();
	out << close_element(SYMBOL);
}
Example #2
0
void xml_cg_formatter::
output_symbol_core(ostream & out, cg_symbol::children const cg_symb,
       string const selfname, string const qname,
       size_t lo, size_t hi, bool is_module, tag_t tag)
{
	cg_symbol::children::const_iterator cit;
	cg_symbol::children::const_iterator cend = cg_symb.end();

	for (cit = cg_symb.begin(); cit != cend; ++cit) {
		string const & module = get_image_name((cit)->image_name,
			image_name_storage::int_filename, extra_found_images);
		bool self = false;
		ostringstream str;
		size_t indx;

		// output symbol's summary data for each profile class
		for (size_t p = lo; p <= hi; ++p)
			xml_support->output_summary_data(str, cit->sample.counts, p);

		if (cverb << vxml)
			out << "<!-- symbol_ref=" << symbol_names.name(cit->name) <<
				" -->" << endl;

		if (is_module) {
			out << open_element(MODULE, true);
			out << init_attr(NAME, module) << close_element(NONE, true);
		}

		out << open_element(SYMBOL, true);

		string const symname = symbol_names.name(cit->name);
		assert(symname.size() > 0);

		string const symqname = module + ":" + symname;

		// Find any self references and handle
		if ((symname == selfname) && (tag == CALLEES)) {
			self = true;
			indx = xml_get_symbol_index(qname);
		} else {
			indx = xml_get_symbol_index(symqname);
		}

		out << init_attr(ID_REF, indx);

		if (self)
			out << init_attr(SELFREF, "true");

		out << close_element(NONE, true);
		out << str.str();
		out << close_element(SYMBOL);

		if (is_module)
			out << close_element(MODULE);
	}
}
Example #3
0
string  xml_formatter::
output_symbol_details(symbol_entry const * symb,
    size_t & detail_index, size_t const lo, size_t const hi)
{
	if (!has_sample_counts(symb->sample.counts, lo, hi))
		return "";

	sample_container::samples_iterator it = profile->begin(symb);
	sample_container::samples_iterator end = profile->end(symb);

	ostringstream str;
	for (; it != end; ++it) {
		counts_t c;

		for (size_t p = lo; p <= hi; ++p)  {
			size_t count = it->second.counts[p];

			if (count == 0) continue;

			str << open_element(DETAIL_DATA, true);
			str << init_attr(TABLE_ID, detail_index++);

			// first output the vma field
			field_datum datum(*symb, it->second, 0, c, 
					  extra_found_images, 0.0);
			output_attribute(str, datum, ff_vma, VMA);
			if (flags & ff_linenr_info) {
				string sym_file;
				size_t sym_line;
				string samp_file;
				size_t samp_line;
				string sym_info = get_linenr_info(symb->sample.file_loc, true);
				string samp_info = get_linenr_info(it->second.file_loc, true);

				if (extract_linenr_info(samp_info, samp_file, samp_line)) {
					if (extract_linenr_info(sym_info, sym_file, sym_line)) {
						// only output source_file if it is different than the symbol's 
						// source file.  this can happen with inlined functions in
						// #included header files
						if (sym_file != samp_file)
							str << init_attr(SOURCE_FILE, samp_file);
					}
					str << init_attr(SOURCE_LINE, samp_line);
				}
			}
			str << close_element(NONE, true);

			// output buffered sample data
			output_sample_data(str, it->second, p);

			str << close_element(DETAIL_DATA);
		}
	}
	return str.str();
}
Example #4
0
void xml_formatter::output(ostream & out)
{
	xml_support->build_subclasses(out);

	xml_support->output_program_structure(out);
	output_symbol_data(out);
	if (need_details) {
		out << open_element(DETAIL_TABLE);
		for (size_t i = 0; i < symbol_details.size(); ++i) {
			int id = symbol_details[i].id;

			if (id >= 0) {
				out << open_element(SYMBOL_DETAILS, true);
				out << init_attr(TABLE_ID, (size_t)id);
				out << close_element(NONE, true);
				out << symbol_details[i].details;
				out << close_element(SYMBOL_DETAILS);
			}
		}
		out << close_element(DETAIL_TABLE);

		// output bytesTable
		out << open_element(BYTES_TABLE);
		out << bytes_out.str();
		out << close_element(BYTES_TABLE);
	}

	out << close_element(PROFILE);
}
Example #5
0
void xml_formatter::
output_sample_data(ostream & out, sample_entry const & sample, size_t pclass)
{
	out << open_element(COUNT, true);
	out << init_attr(CLASS, classes.v[pclass].name);
	out << close_element(NONE, true);
	out << sample.counts[pclass];
	out << close_element(COUNT);
}
Example #6
0
static WMenuEntry *preprocess_menu(ExtlTab tab, int *n_entries)
{
    WMenuEntry *entries;
    ExtlTab entry;
    int i, n;
    
    n=extl_table_get_n(tab);
    *n_entries=n;
    
    if(n<=0)
        return NULL;

    entries=ALLOC_N(WMenuEntry, n);  
    
    if(entries==NULL)
        return NULL;
        
    init_attr();
    
    /* Initialise entries and check submenus */
    for(i=1; i<=n; i++){
        WMenuEntry *ent=&entries[i-1];
        
        ent->title=NULL;
        ent->flags=0;
        
        gr_stylespec_init(&ent->attr);
        
        if(extl_table_geti_t(tab, i, &entry)){
            char *attr;
            ExtlTab sub;
            ExtlFn fn;
            
            if(extl_table_gets_s(entry, "attr", &attr)){
                gr_stylespec_load_(&ent->attr, attr, TRUE);
                free(attr);
            }
            
            if(extl_table_gets_f(entry, "submenu_fn", &fn)){
                ent->flags|=WMENUENTRY_SUBMENU;
                extl_unref_fn(fn);
            }else if(extl_table_gets_t(entry, "submenu", &sub)){
                ent->flags|=WMENUENTRY_SUBMENU;
                extl_unref_table(sub);
            }
            
            if(ent->flags&WMENUENTRY_SUBMENU)
                gr_stylespec_set(&ent->attr, GR_ATTR(submenu));
            
            extl_unref_table(entry);
        }
    }
    
    return entries;
}
Example #7
0
void xml_formatter::
output_attribute(ostream & out, field_datum const & datum,
                 format_flags fl, tag_t tag)
{
	field_description const & field(format_map[fl]);

	string str = (this->*field.formatter)(datum);

	if (!str.empty()) {
		if (fl == ff_linenr_info && (tag == SOURCE_LINE || tag == SOURCE_FILE)) {
			string file;
			size_t line;

			if (extract_linenr_info(str, file, line)) {
				if (tag == SOURCE_LINE)
					out << init_attr(tag, line);
				else
					out << init_attr(tag, file);
			}
		} else
			out << " " << init_attr(tag, str);
	}
}
Example #8
0
void xml_cg_formatter::
output_symbol(ostream & out,
	symbol_entry const * symb, size_t lo, size_t hi, bool is_module)
{
	cg_symbol const * cg_symb = dynamic_cast<cg_symbol const *>(symb);
	ostringstream str;
	size_t indx;

	// output symbol's summary data for each profile class
	for (size_t p = lo; p <= hi; ++p)
		xml_support->output_summary_data(str, symb->sample.counts, p);

	if (cverb << vxml)
		out << "<!-- symbol_ref=" << symbol_names.name(symb->name) <<
			" -->" << endl;

	out << open_element(SYMBOL, true);

	string const name = symbol_names.name(symb->name);
	assert(name.size() > 0);

	string const image = get_image_name(symb->image_name,
		image_name_storage::int_filename, extra_found_images);
	string const qname = image + ":" + name;

	string const selfname = symbol_names.demangle(symb->name) + " [self]";

	indx = xml_get_symbol_index(qname);

	out << init_attr(ID_REF, indx);

	out << close_element(NONE, true);

	out << open_element(CALLERS);
	if (cg_symb)
		output_symbol_core(out, cg_symb->callers, selfname, qname, lo, hi, is_module, CALLERS);
	out << close_element(CALLERS);

	out << open_element(CALLEES);
	if (cg_symb)
		output_symbol_core(out, cg_symb->callees, selfname, qname, lo, hi, is_module, CALLEES);

	out << close_element(CALLEES);

	// output summary
	out << str.str();
	out << close_element(SYMBOL);
}
Example #9
0
File: 1-6.c Project: 1587/ltp
static void run_hp_threads(int sched_policy, int sched_prio)
{
	struct itimerval it;
	pthread_t threads[n_threads];
	pthread_attr_t attr;
	int i, ret;

	flag = 1;

	it.it_interval.tv_sec = 0;
	it.it_interval.tv_usec = 0;
	it.it_value.tv_sec = n_threads / 20;
	it.it_value.tv_usec = (n_threads % 20) * 50000;

	init_attr(&attr, sched_policy, sched_prio);

	if (signal(SIGPROF, alarm_handler) == SIG_ERR) {
		perror("signal()");
		exit(PTS_UNRESOLVED);
	}

	if (setitimer(ITIMER_PROF, &it, NULL)) {
		perror("setitimer(ITIMER_VIRTUAL, ...)");
		exit(PTS_UNRESOLVED);
	}

	for (i = 0; i < n_threads; i++) {
		ret = pthread_create(&threads[i], &attr, do_work, NULL);
		if (ret) {
			fprintf(stderr, "pthread_create(): %s\n",
			        strerror(ret));
			exit(PTS_UNRESOLVED);
		}
	}

	if (flag) {
		printf("FAILED: low priority thread scheduled\n");
		exit(PTS_FAIL);
	}

	pthread_attr_destroy(&attr);

	for (i = 0; i < n_threads; i++)
		pthread_join(threads[i], NULL);

}
Example #10
0
File: 1-6.c Project: 1587/ltp
int main(void)
{
	pthread_attr_t attr;
	pthread_t th;
	struct params p;
	int ret;
	unsigned int i;

	ret = set_affinity_single();
	if (ret) {
		n_threads = get_ncpu();
		if (n_threads == -1) {
			printf("Cannot get number of CPUs\n");
			return PTS_UNRESOLVED;
		}
		printf("INFO: Affinity not supported, running %i threads.\n",
		       n_threads);
	} else {
		printf("INFO: Affinity works, will use only one thread.\n");
		n_threads = 1;
	}

	for (i = 0; i < ARRAY_SIZE(tcases); i++) {
		p.sched_policy = tcases[i].sched_policy;
		p.sched_priority = get_prio(&tcases[i]);

		init_attr(&attr, p.sched_policy, p.sched_priority);

		printf("INFO: Testing %s prio %i\n",
		       sched_policy_name(p.sched_policy), p.sched_priority);

		ret = pthread_create(&th, &attr, do_test, &p);
		if (ret) {
			fprintf(stderr, "pthread_create(): %s\n", strerror(ret));
			return PTS_UNRESOLVED;
		}

		pthread_join(th, NULL);

		pthread_attr_destroy(&attr);
	}

	printf("Test PASSED\n");
	return 0;
}
Example #11
0
void xml_formatter::
output_the_symbol_data(ostream & out, symbol_entry const * symb, op_bfd * & abfd)
{
	string const name = symbol_names.name(symb->name);
	assert(name.size() > 0);

	string const image = get_image_name(symb->image_name,
		image_name_storage::int_filename, extra_found_images);
	string const qname = image + ":" + name;
	map<string, size_t>::iterator sd_it = symbol_data_table.find(qname);

	if (sd_it != symbol_data_table.end()) {
		// first time we've seen this symbol
		out << open_element(SYMBOL_DATA, true);
		out << init_attr(TABLE_ID, sd_it->second);

		field_datum datum(*symb, symb->sample, 0, counts,
				  extra_found_images);

		output_attribute(out, datum, ff_symb_name, NAME);

		if (flags & ff_linenr_info) {
			output_attribute(out, datum, ff_linenr_info, SOURCE_FILE);
			output_attribute(out, datum, ff_linenr_info, SOURCE_LINE);
		}

		if (name.size() > 0 && name[0] != '?') {
			output_attribute(out, datum, ff_vma, STARTING_ADDR);

			if (need_details) {
				get_bfd_object(symb, abfd);
				if (abfd && abfd->symbol_has_contents(symb->sym_index))
					xml_support->output_symbol_bytes(bytes_out, symb, sd_it->second, *abfd);
			}
		}
		out << close_element();

		// seen so remove (otherwise get several "no symbols")
		symbol_data_table.erase(qname);
	}
}
Example #12
0
bool menu_init(WMenu *menu, WWindow *par, const WFitParams *fp,
               const WMenuCreateParams *params)
{
    Window win;
    int i;
    
    menu->entries=preprocess_menu(params->tab, &(menu->n_entries));
    
    if(menu->entries==NULL){
        warn(TR("Empty menu."));
        return FALSE;
    }

    menu->tab=extl_ref_table(params->tab);
    menu->handler=extl_ref_fn(params->handler);
    menu->pmenu_mode=params->pmenu_mode;
    menu->big_mode=params->big_mode;
    /*menu->cycle_bindmap=NULL;*/
    
    menu->last_fp=*fp;
    
    if(params->pmenu_mode){
        menu->selected_entry=-1;
    }else{
        menu->selected_entry=params->initial-1;
        if(menu->selected_entry<0)
           menu->selected_entry=0;
        if(params->initial > menu->n_entries)
           menu->selected_entry=0;
    }
    
    menu->max_entry_w=0;
    menu->entry_h=0;
    menu->brush=NULL;
    menu->entry_brush=NULL;
    menu->entry_spacing=0;
    menu->vis_entries=menu->n_entries;
    menu->first_entry=0;
    menu->submenu=NULL;
    menu->typeahead=NULL;
    
    menu->gm_kcb=0;
    menu->gm_state=0;
    
    if(!window_init((WWindow*)menu, par, fp))
        goto fail;

    win=menu->win.win;
    
    if(!menu_init_gr(menu, region_rootwin_of((WRegion*)par), win))
        goto fail2;
        
    init_attr();
    
    menu_firstfit(menu, params->submenu_mode, &(params->refg));
    
    window_select_input(&(menu->win), IONCORE_EVENTMASK_NORMAL);
    
    region_add_bindmap((WRegion*)menu, mod_menu_menu_bindmap);
    
    region_register((WRegion*)menu);
    
    return TRUE;

fail2:
    window_deinit((WWindow*)menu);
fail:
    extl_unref_table(menu->tab);
    extl_unref_fn(menu->handler);
    deinit_entries(menu);
    return FALSE;
}
int main(int argc, char* argv[]) 
{

/****************************Success Test*******************************/

/*testcase 1
* create target success
*
*
* @result windows initiator in acls could connected
*/
    iscsi_del_all_targets();
    init_target();
    init_sobj();
    init_portal();
    init_para();
    init_attr();

    printf("Testcase1\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();


/*testcase 2-1
* set tpg mutual auth 
*
*
* @result windows initiator in acls could connected in mutual chap
* learn more from RTSlib_Test.doc in Z:\test-tools\RTSlib&iscsi\RTSlib_Test
*/
    iscsi_del_all_targets();

    init_sobj();

    target = (iscsitarget_t*)malloc(sizeof(iscsitarget_t));
    strcpy(target->chap_mutual_password, "56789987655678");
    strcpy(target->chap_mutual_userid, "iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(target->chap_password, "123455432112");
    strcpy(target->chap_userid, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");
    target->enable = 1;
    target->tag = 1;
    target->node_acls_num = 2;
    strcpy((target->node_acls)[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy((target->node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");

    init_portal();
    init_para();

    target->attrib = (attributes_t*)malloc(sizeof(attributes_t));
    target->attrib->authentication = 1;
    target->attrib->cache_dynamic_acls = 1;
    target->attrib->default_cmdsn_depth = 16;
    target->attrib->demo_mode_write_protect = 0;
    target->attrib->generate_node_acls = 1;// for tpg
    target->attrib->login_timeout = 15;
    target->attrib->netif_timeout = 2;
    target->attrib->prod_mode_write_protect = 0;

    printf("Testcase2-1\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();


/*testcase 2-2
* set acl mutual auth 
*
*
* @result windows initiator in acls could connected in mutual chap
* learn more from RTSlib_Test.doc in Z:\test-tools\RTSlib&iscsi\RTSlib_Test
*/
    iscsi_del_all_targets();

    init_sobj();

    target = (iscsitarget_t*)malloc(sizeof(iscsitarget_t));
    strcpy(target->chap_mutual_password, "56789987655678");
    strcpy(target->chap_mutual_userid, "iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(target->chap_password, "123455432112");
    strcpy(target->chap_userid, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");
    target->enable = 1;
    target->tag = 1;
    target->node_acls_num = 0;
    strcpy((target->node_acls)[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy((target->node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");

    init_portal();
    init_para();

    target->attrib = (attributes_t*)malloc(sizeof(attributes_t));
    target->attrib->authentication = 1;
    target->attrib->cache_dynamic_acls = 1;
    target->attrib->default_cmdsn_depth = 16;
    target->attrib->demo_mode_write_protect = 0;
    target->attrib->generate_node_acls = 0;// for acl
    target->attrib->login_timeout = 15;
    target->attrib->netif_timeout = 2;
    target->attrib->prod_mode_write_protect = 0;

    printf("Testcase2-2\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();

/*testcase 3 
* delete the ACLs mutual auth  
*
*
* @result windows initiator in acls could connected
*/
    iscsi_del_all_targets();
    init_target();
    init_sobj();
    init_portal();
    init_para();
    init_attr();

    printf("Testcase3\n");
    iscsi_create_target(sobj, target);
    iscsi_set_ACLs_auth(target->wwn, target->tag, target->node_acls, target->node_acls_num, target->chap_mutual_userid, target->chap_mutual_password, target->chap_userid, target->chap_password);
    iscsi_del_ACLs_auth(target->wwn, target->tag);

    show_targetcli();
    free_all();


/* testcase 4-1
* delete the target of wwn whihout the target
*
* @result backstore do not delete
*/
    iscsi_del_all_targets();
    init_target();
    init_sobj();
    init_portal();
    init_para();
    init_attr();

    printf("Testcase4-1\n");
    iscsi_create_target(sobj, target);
    iscsi_del_target(false,target->wwn);

    show_targetcli();
    free_all();

/* testcase 4-2 
* delete the target of wwn with the target
*
*/
    iscsi_del_all_targets();
    init_target();
    init_sobj();
    init_portal();
    init_para();
    init_attr();

    printf("Testcase4-2\n");
    iscsi_create_target(sobj, target);
    iscsi_del_target(true,target->wwn);

    show_targetcli();
    free_all();

/* testcase 5 
*create fileio target
*
* @parameter change
*   sobj = (storage_obj_t*)malloc(sizeof(storage_obj_t));
*   strcpy(sobj->dev,"/root/Desktop/LibreOffice_4.4.4_Win_x86.msi");//214 MB(224,423,936)
*   strcpy(sobj->name,"LibreOffice_4");
*   sobj->iscsi_plugin = 1;
*   sobj->size = 12345;
*
*/  iscsi_del_all_targets();

    /* initialize the storeobject */
    sobj = (storage_obj_t*)malloc(sizeof(storage_obj_t));
    strcpy(sobj->dev,"/root/Desktop/LibreOffice_4.4.4_Win_x86.msi");
    strcpy(sobj->name,"LibreOffice_4");
    sobj->iscsi_plugin = 1;
    sobj->size = 12345;

    init_target();
    init_portal();
    init_para();
    init_attr();

    printf("Testcase5\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();



/****************************Error Test*******************************/

/* testcase 6
*create backstore whith file error 
*
*
* @method input fileiosize is larger than real fileiosize
*  
*
* @result create the file with the input size
*/
    iscsi_del_all_targets();

    /* initialize the storeobject */
    sobj = (storage_obj_t*)malloc(sizeof(storage_obj_t));
    strcpy(sobj->dev,"/root/Desktop/LibreOffice_4.4.4_Win_x86.msi");//214m(224,423,936)
    strcpy(sobj->name,"LibreOffice_4");
    sobj->iscsi_plugin = 1;
    sobj->size = 53687091200;

    init_target();
    init_portal();
    init_para();
    init_attr();

    printf("Testcase6\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();

/* testcase 7
*create backstore whith file error
*
*
* @method input fileiosize is 0
*  
*
* @result return  file with size 0
*/
    iscsi_del_all_targets();

    /* initialize the storeobject */
    sobj = (storage_obj_t*)malloc(sizeof(storage_obj_t));
    strcpy(sobj->dev,"/root/Desktop/LibreOffice_4.4.4_Win_x86.msi");//214m(224,423,936)
    strcpy(sobj->name,"LibreOffice_4");
    sobj->iscsi_plugin = 1;
    sobj->size = 0;//

    init_target();
    init_portal();
    init_para();
    init_attr();

    printf("Testcase7\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();

/* testcase 8
*create backstore whith file error
*
*
* @method give filesize -2
*  
*
* @result  no thing establshed
*/
    iscsi_del_all_targets();

    /* initialize the storeobject */
    sobj = (storage_obj_t*)malloc(sizeof(storage_obj_t));
    strcpy(sobj->dev,"/root/Desktop/iscsitest12");//214m(224,423,936)
    strcpy(sobj->name,"test12");
    sobj->iscsi_plugin =1;
    sobj->size = -2;
    

    init_target();
    init_portal();
    init_para();
    init_attr();

    printf("Testcase8\n");
    iscsi_create_target(sobj, target);

    //iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();



/* testcase 8-2
*create backstore whith file error
*
*
* @method give the file path but put the plugin in to 2
*  
*
* @result  Device is not a TYPE_DISK block device
*/
    iscsi_del_all_targets();

    /* initialize the storeobject */
    sobj = (storage_obj_t*)malloc(sizeof(storage_obj_t));
    strcpy(sobj->dev,"/root/Desktop/iscsitest12");//214m(224,423,936)
    strcpy(sobj->name,"test12");
    sobj->iscsi_plugin = 2;
    

    init_target();
    init_portal();
    init_para();
    init_attr();

    printf("Testcase8-1\n");
    iscsi_create_target(sobj, target);

    //iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();

/* testcase 8-3
*create backstore whith file error
*
*
* @method don not give the iqn
*  
*
* @result  WWN not valid as: iqn, naa, eui nothing esablish
*/
    iscsi_del_all_targets();


    init_sobj();

    target = (iscsitarget_t*)malloc(sizeof(iscsitarget_t));
    strcpy(target->chap_mutual_password, "567899876556");
    strcpy(target->chap_mutual_userid, "iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(target->chap_password, "123455432112");
    strcpy(target->chap_userid, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");
    target->enable = 1;
    target->tag = 1;
    target->node_acls_num = 2;
    strcpy((target->node_acls)[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy((target->node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    //strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");


    init_portal();
    init_para();
    init_attr();

    printf("Testcase8-3\n");
    iscsi_create_target(sobj, target);

    //iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();

/* testcase 8-4
*create backstore whith file multi error
*
*
* @method don not give the iqn ip_address
*  
*
* @result return 0 for step_3,4,5,6 sucess : -1 nothing esablish
*/
    iscsi_del_all_targets();


    init_sobj();

    target = (iscsitarget_t*)malloc(sizeof(iscsitarget_t));
    strcpy(target->chap_mutual_password, "567899876556");
    strcpy(target->chap_mutual_userid, "iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(target->chap_password, "123455432112");
    strcpy(target->chap_userid, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");
    //target->enable = 1;
    //target->tag = 1;
    target->node_acls_num = 2;
    strcpy((target->node_acls)[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy((target->node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");


    init_para();
    target->portal = (portals_t*)malloc(sizeof(portals_t));
    strcpy(target->portal->ip_address, "192.168.1.77"); 
    target->portal->iser = 1;
    target->portal->port = 3260;
    init_attr();

    printf("Testcase8-4\n");
    iscsi_create_target(sobj, target);

    //iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();




/* testcase 9
*create backstore whith file error
*
*
* @method input file not exist and do not give the size
*  
*
* @result no size created but the object still exist
*/
    iscsi_del_all_targets();

    /* initialize the storeobject */
    sobj = (storage_obj_t*)malloc(sizeof(storage_obj_t));
    strcpy(sobj->dev,"/root/Desktop/not_exist");//214m(224,423,936)
    strcpy(sobj->name,"LibreOffice_4");
    sobj->iscsi_plugin = 1;
    //sobj->size = 0;//

    init_target();
    init_portal();
    init_para();
    init_attr();

    printf("Testcase9\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();
    
/* testcase 10
*create backstore whith file error
*
*
* @method input file not exist and give the size
*  
*
* @result create the file with the size given
*/
    iscsi_del_all_targets();

    /* initialize the storeobject */
    sobj = (storage_obj_t*)malloc(sizeof(storage_obj_t));
    strcpy(sobj->dev,"/root/Desktop/not_exist");//214m(224,423,936)
    strcpy(sobj->name,"not_exist");
    sobj->iscsi_plugin = 1;
    sobj->size = 536870912;//

    init_target();
    init_portal();
    init_para();
    init_attr();

    printf("Testcase10\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();

/* testcase 11
*create backstore whith file error
*
*
* @method input file but the iscsi_plugin is block
*  
*
* @result  Device is not a TYPE_DISK block device.
* nothing establishes
*/
    iscsi_del_all_targets();

    /* initialize the storeobject */
    sobj = (storage_obj_t*)malloc(sizeof(storage_obj_t));
    strcpy(sobj->dev,"/root/Desktop/LibreOffice_4.4.4_Win_x86.msi");//214m(224,423,936)
    strcpy(sobj->name,"LibreOffice_4");
    sobj->iscsi_plugin = 2;
    sobj->size = 536870912;//

    init_target();
    init_portal();
    init_para();
    init_attr();

    printf("Testcase11\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();


/* testcase 12
*create backstore whith file error
*
*
* @method input error filepath 
*  
* @result [Errno 2] No such file or directory
* nothing established
*/
    iscsi_del_all_targets();

    /* initialize the storeobject */
    sobj = (storage_obj_t*)malloc(sizeof(storage_obj_t));
    strcpy(sobj->dev,"dev/sdb");
    strcpy(sobj->name,"disk_b");
    sobj->iscsi_plugin =1;
    sobj->size = 536870912;//512m

    init_target();
    init_portal();
    init_para();
    init_attr();

    printf("Testcase12\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();


/* testcase 13
*create backstore whith block error
*
*
* @method input error block path 
*  
* @result [Errno 2] No such file or directory
* nothing established
*/
    iscsi_del_all_targets();

    /* initialize the storeobject */
    sobj = (storage_obj_t*)malloc(sizeof(storage_obj_t));
    strcpy(sobj->dev,"dev/sdb");
    strcpy(sobj->name,"disk_b");
    sobj->iscsi_plugin = 2;
    sobj->size = 536870912;//512m

    init_target();
    init_portal();
    init_para();
    init_attr();

    printf("Testcase13\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();

/* testcase 14
*create backstore whith iscsi_plugin error
*
*
* @method input error iscsi_plugin number 
*  
* @result nothing established
*/
    iscsi_del_all_targets();

    /* initialize the storeobject */
    sobj = (storage_obj_t*)malloc(sizeof(storage_obj_t));
    strcpy(sobj->dev,"dev/sdb");
    strcpy(sobj->name,"disk_b");
    sobj->iscsi_plugin = 3;
    sobj->size = 536870912;//512m

    init_target();
    init_portal();
    init_para();
    init_attr();

    printf("Testcase14\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();


/* testcase 15
*create backstore whith iscsi_plugin error
*
*
* @method input  iscsi_plugin 0
*  
* @result nothing established
*/
    iscsi_del_all_targets();

    /* initialize the storeobject */
    sobj = (storage_obj_t*)malloc(sizeof(storage_obj_t));
    strcpy(sobj->dev,"dev/sdb");
    strcpy(sobj->name,"disk_b");
    sobj->iscsi_plugin = 0;
    sobj->size = 536870912;//512m

    init_target();
    init_portal();
    init_para();
    init_attr();

    printf("Testcase15\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();



/* testcase 16
*create target whith target error
* @default(fileio)
*
* @method input  target->wwn is empty
* 
* @result WWN not valid as: iqn, naa, eui
* return 0 for create_target success : -1
* nothing established
*/
    iscsi_del_all_targets();

    init_sobj();

    target = (iscsitarget_t*)malloc(sizeof(iscsitarget_t));
    strcpy(target->chap_mutual_password, "567899876556");
    strcpy(target->chap_mutual_userid, "iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(target->chap_password, "123455432112");
    strcpy(target->chap_userid, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");
    target->enable = 1;
    target->tag = 1;
    target->node_acls_num = 2;
    strcpy((target->node_acls)[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy((target->node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(target->wwn, "");
 
    init_portal();
    init_para();
    init_attr();

    printf("Testcase16\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();

/* testcase 17
*create target whith target error
* @default(fileio)
*
* @method input  target->wwn  is aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
*  
* @result WWN not valid as: iqn, naa, eui
* return 0 for create_target success : -1
* nothing established
*/
    iscsi_del_all_targets();

    init_sobj();

    target = (iscsitarget_t*)malloc(sizeof(iscsitarget_t));
    strcpy(target->chap_mutual_password, "567899876556");
    strcpy(target->chap_mutual_userid, "iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(target->chap_password, "123455432112");
    strcpy(target->chap_userid, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");
    target->enable = 1;
    target->tag = 1;
    target->node_acls_num = 2;
    strcpy((target->node_acls)[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy((target->node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(target->wwn, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

    init_portal();
    init_para();
    init_attr();

    printf("Testcase17\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();


/* testcase 18
*create tpg whith target error
* @default(fileio)
*
* @method input  target->tag = 2;
*  
* @result nothing established
*/
    iscsi_del_all_targets();

    init_sobj();

    target = (iscsitarget_t*)malloc(sizeof(iscsitarget_t));
    strcpy(target->chap_mutual_password, "567899876556");
    strcpy(target->chap_mutual_userid, "iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(target->chap_password, "123455432112");
    strcpy(target->chap_userid, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");
    target->enable = 1;
    target->tag = 2;
    target->node_acls_num = 2;
    strcpy((target->node_acls)[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy((target->node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");

    init_portal();
    init_para();
    init_attr();

    printf("Testcase18\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();

/* testcase 19
*create tpg whith portals error
* @default(fileio)
*
* @method input  target->portal->ip_address is "0.0.0.0"
*  
* @result no error
*/
    iscsi_del_all_targets();

    init_sobj();
    init_target();

    target->portal = (portals_t*)malloc(sizeof(portals_t));
    strcpy(target->portal->ip_address, "0.0.0.0"); 
    target->portal->iser = 1;
    target->portal->port = 3260;

    init_para();
    init_attr();

    printf("Testcase19\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();

/* testcase 20
*create tpg whith portals error
* @default(fileio)
*
* @method input  portal->ip_address "225.225.225.225"
*  
* @result no error
*/
    iscsi_del_all_targets();

    init_sobj();
    init_target();

    target->portal = (portals_t*)malloc(sizeof(portals_t));
    strcpy(target->portal->ip_address, "225.225.225.225"); 
    target->portal->iser = 1;
    target->portal->port = 3260;

    init_para();
    init_attr();

    printf("Testcase20\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();


/* testcase 21
*create tpg whith portals error
* @default(fileio)
*
* @method input  portal->ip_address 0000
*  
*
* @result no error
*/

    iscsi_del_all_targets();

    init_sobj();
    init_target();

    target->portal = (portals_t*)malloc(sizeof(portals_t));
    strcpy(target->portal->ip_address, "0000"); 
    target->portal->iser = 1;
    target->portal->port = 3260;

    init_para();
    init_attr();

    printf("Testcase21\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();

/* testcase 22
* create the portals 0.0.0.0:3260 in another target 
*
* @method set the portals 0.0.0.0  
*
*
* @result could not create ip potals 0.0.0.0:3260 in another target
*/
    iscsi_del_all_targets();
    init_target();
    init_sobj();
    init_portal();
    init_para();
    init_attr();

    printf("Testcase22\n");
    iscsi_create_target(sobj, target);
    show_targetcli();
    free_all();


    init_target();
    init_sobj();
    init_portal();
    init_para();
    init_attr();
    strcpy(sobj->dev,"/dev/sdd");
    strcpy(sobj->name,"disk_d");
    strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb5");
    strcpy(target->portal->ip_address, "0.0.0.0"); 
    iscsi_create_target(sobj, target);



    show_targetcli();
    free_all();

/* testcase 23
* create the same portals in another target 
*
* @method give the same ip
*
*
* @result  return success target with same ip portals
* initiator could see 2 target
*/
    iscsi_del_all_targets();
    init_target();
    init_sobj();
    init_portal();
    init_para();
    init_attr();

    printf("Testcase23\n");
    iscsi_create_target(sobj, target);
    show_targetcli();
    free_all();


    init_target();
    init_sobj();
    init_portal();
    init_para();
    init_attr();
    strcpy(sobj->dev,"/dev/sdd");
    strcpy(sobj->name,"disk_d");
    strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb5");
    strcpy(target->portal->ip_address, "192.168.1.77"); 
    iscsi_create_target(sobj, target);



    show_targetcli();
    free_all();

/* testcase 24
* create the portals 0.0.0.0:3260 in first target and create another target of ip partals 192.168.1.77
*
* @method set the first portals 0.0.0.0  second target portal 192.168.1.77
*
*
* @result could not create ip potals 192.168.1.77 in another target
*/
    iscsi_del_all_targets();
    init_target();
    init_sobj();
    init_portal();
    init_para();
    init_attr();
    strcpy(sobj->dev,"/dev/sdd");
    strcpy(sobj->name,"disk_d");
    strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb5");
    strcpy(target->portal->ip_address, "0.0.0.0"); 


    printf("Testcase24\n");
    iscsi_create_target(sobj, target);
    show_targetcli();
    free_all();


    init_target();
    init_sobj();
    init_portal();
    init_para();
    init_attr();
    iscsi_create_target(sobj, target);



    show_targetcli();
    free_all();


/*testcase 25?
*create tpg do not enable tpg
* @default(fileio)
*
* @method input  target->enable =0
*
*
* @result 
*/
    iscsi_del_all_targets();
    init_target();
    init_sobj();
    init_portal();
    init_para();
    init_attr();
    target->enable =0;


    printf("Testcas25\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();

/*testcase 26
*create tpg with enable fault
* @default(fileio)
*
* @method input  target->enable=ii
*
*
* @result 
*/
    iscsi_del_all_targets();
    init_target();
    init_sobj();
    init_portal();
    init_para();
    init_attr();
    target->enable =99;


    printf("Testcas26\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();

/* testcase 27
*create target whith attribute error
* @default(fileio)
*
* @method input  target->chap_mutual_password excced 16 bytes
*  
* @result mutual_password=56789987655678abiqn.1991-05.com.microsoft:ibm-t410s
*/
    iscsi_del_all_targets();

    init_sobj();

    target = (iscsitarget_t*)malloc(sizeof(iscsitarget_t));
    strcpy(target->chap_mutual_password, "56789987655678abcdefghijkl");
    strcpy(target->chap_mutual_userid, "iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(target->chap_password, "123455432112");
    strcpy(target->chap_userid, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");
    target->enable = 1;
    target->tag = 1;
    target->node_acls_num = 2;
    strcpy((target->node_acls)[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy((target->node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");

    init_portal();
    init_para();
    init_attr();

    printf("Testcase27\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();

/* testcase 28
*create target whith attribute error
* @default(fileio)
*
* @method input  target->chap_mutual_password less 12 bytes
*  
* @result  establish success,but when you connected by windows initiator 
* the system will give the error hint about the password format
*/
    iscsi_del_all_targets();

    init_sobj();

    target = (iscsitarget_t*)malloc(sizeof(iscsitarget_t));
    strcpy(target->chap_mutual_password, "567");
    strcpy(target->chap_mutual_userid, "iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(target->chap_password, "123455432112");
    strcpy(target->chap_userid, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");
    target->enable = 1;
    target->tag = 1;
    target->node_acls_num = 2;
    strcpy((target->node_acls)[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy((target->node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");

    init_portal();
    init_para();

    target->attrib = (attributes_t*)malloc(sizeof(attributes_t));
    target->attrib->authentication = 1;
    target->attrib->cache_dynamic_acls = 1;
    target->attrib->default_cmdsn_depth = 16;
    target->attrib->demo_mode_write_protect = 0;
    target->attrib->generate_node_acls = 0;// for acl
    target->attrib->login_timeout = 15;
    target->attrib->netif_timeout = 2;
    target->attrib->prod_mode_write_protect = 0;

    printf("Testcase28\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();

/* testcase 29
*create target whith attribute error
* @default(fileio)
*
* @method input  target->chap_mutual_userid not a proper name
*  
* @result nothing error
*/
    iscsi_del_all_targets();

    init_sobj();

    target = (iscsitarget_t*)malloc(sizeof(iscsitarget_t));
    strcpy(target->chap_mutual_password, "567899876556");
    strcpy(target->chap_mutual_userid, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
    strcpy(target->chap_password, "123455432112");
    strcpy(target->chap_userid, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");
    target->enable = 1;
    target->tag = 1;
    target->node_acls_num = 2;
    strcpy((target->node_acls)[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy((target->node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");

    init_portal();
    init_para();

    target->attrib = (attributes_t*)malloc(sizeof(attributes_t));
    target->attrib->authentication = 1;
    target->attrib->cache_dynamic_acls = 1;
    target->attrib->default_cmdsn_depth = 16;
    target->attrib->demo_mode_write_protect = 0;
    target->attrib->generate_node_acls = 0;// for acl
    target->attrib->login_timeout = 15;
    target->attrib->netif_timeout = 2;
    target->attrib->prod_mode_write_protect = 0;

    printf("Testcase29\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();

/* testcase 30
*create target whith attribute error
*
*
* @method input  target->node_acls_num  is bigger than the list
*  
* @result nothing established
*/
    iscsi_del_all_targets();

    init_sobj();

    target = (iscsitarget_t*)malloc(sizeof(iscsitarget_t));
    strcpy(target->chap_mutual_password, "567899876556");
    strcpy(target->chap_mutual_userid, "iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(target->chap_password, "123455432112");
    strcpy(target->chap_userid, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");
    target->enable = 1;
    target->tag = 1;
    target->node_acls_num = 4;
    strcpy((target->node_acls)[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy((target->node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");

    init_portal();
    init_para();
    init_attr();

    printf("Testcase30\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();

/* testcase 31
*create target whith attribute error
* 
*
* @method input  target->node_acls_num  is smaller than the list
*  
* @result established the  number of  (target->node_acls_num) initiator
*/
    iscsi_del_all_targets();

    init_sobj();

    target = (iscsitarget_t*)malloc(sizeof(iscsitarget_t));
    strcpy(target->chap_mutual_password, "567899876556");
    strcpy(target->chap_mutual_userid, "iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(target->chap_password, "123455432112");
    strcpy(target->chap_userid, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");
    target->enable = 1;
    target->tag = 1;
    target->node_acls_num = 1;
    strcpy((target->node_acls)[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy((target->node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");

    init_portal();
    init_para();
    init_attr();

    printf("Testcase31\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();





/* testcase 32
*create target whith attribute error
* 
*
* @method input  target->node_acls_num  is 0
*  
* @result target established success without acls
*/
    iscsi_del_all_targets();

    init_sobj();

    target = (iscsitarget_t*)malloc(sizeof(iscsitarget_t));
    strcpy(target->chap_mutual_password, "567899876556");
    strcpy(target->chap_mutual_userid, "iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(target->chap_password, "123455432112");
    strcpy(target->chap_userid, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");
    target->enable = 1;
    target->tag = 1;
    target->node_acls_num = 2;
    strcpy((target->node_acls)[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy((target->node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");

    init_portal();
    init_para();
    init_attr();

    printf("Testcase32\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();
    
/* testcase 33
*create target whith attribute error
* 
*
* @method input  target->node_acls last one is empty
*  
* @result WWN not valid as: iqn, naa, eui
* set_initiator failed
* nothing established

*/
    iscsi_del_all_targets();

    init_sobj();

    target = (iscsitarget_t*)malloc(sizeof(iscsitarget_t));
    strcpy(target->chap_mutual_password, "567899876556");
    strcpy(target->chap_mutual_userid, "iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(target->chap_password, "123455432112");
    strcpy(target->chap_userid, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");
    target->enable = 1;
    target->tag = 1;
    target->node_acls_num = 2;
    strcpy((target->node_acls)[0],"");
    strcpy((target->node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");

    init_portal();
    init_para();
    init_attr();

    printf("Testcase33\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();


/* testcase 34
*create target whith attribute error
* 
*
* @method input  target->node_acls first one is empty
*  
* @result WWN not valid as: iqn, naa, eui
* set_initiator failed
* nothing established

*/
    iscsi_del_all_targets();

    init_sobj();

    target = (iscsitarget_t*)malloc(sizeof(iscsitarget_t));
    strcpy(target->chap_mutual_password, "567899876556");
    strcpy(target->chap_mutual_userid, "iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(target->chap_password, "123455432112");
    strcpy(target->chap_userid, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");
    target->enable = 1;
    target->tag = 1;
    target->node_acls_num = 2;
    strcpy((target->node_acls)[0],"");
    strcpy((target->node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");

    init_portal();
    init_para();
    init_attr();

    printf("Testcase34\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    free_all();




/*testcase 35 
* set the ACLs mutual auth all empty 
*
* @method set the auth uncorrect 
*
*
* @result  [1-way auth, Mapped LUNs: 1]
*/
    iscsi_del_all_targets();

    target = (iscsitarget_t*)malloc(sizeof(iscsitarget_t));
    strcpy(target->chap_mutual_password, "");
    strcpy(target->chap_mutual_userid, "");
    strcpy(target->chap_password, "");
    strcpy(target->chap_userid, "");
    target->enable = 1;
    target->tag = 1;
    target->node_acls_num = 2;
    strcpy((target->node_acls)[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy((target->node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");

    init_sobj();
    init_portal();
    init_para();
    init_attr();

    printf("Testcase35\n");
    iscsi_create_target(sobj, target);
    iscsi_set_ACLs_auth(target->wwn, target->tag, target->node_acls, target->node_acls_num, target->chap_mutual_userid, target->chap_mutual_password, target->chap_userid, target->chap_password);

    show_targetcli();
    free_all();


/* testcase 36
* delete the target of wwn 
*
* @method give the wwn which do not exist  
*
*
* @result return 0 for delete the target success : 1
*/
    iscsi_del_all_targets();
    init_target();
    init_sobj();
    init_portal();
    init_para();
    init_attr();

    printf("Testcase36\n");
    iscsi_create_target(sobj, target);
    iscsi_del_target(true,"iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb5");

    show_targetcli();
    free_all();


/* testcase 37
*set acls initiator list
* 
*
* @method input node_acls[i] one of them to 0
*  
* @result established the  target with the acls give
*/
    iscsi_del_all_targets();

    init_sobj();

    target = (iscsitarget_t*)malloc(sizeof(iscsitarget_t));
    strcpy(target->chap_mutual_password, "567899876556");
    strcpy(target->chap_mutual_userid, "iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(target->chap_password, "123455432112");
    strcpy(target->chap_userid, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");
    target->enable = 1;
    target->tag = 1;
    target->node_acls_num = 0;
    strcpy((target->node_acls)[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy((target->node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");

    init_portal();
    init_para();
    init_attr();

    printf("Testcase37\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    char wwn[] = "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4";
    int tag = 1;
    char node_acls[3][MAXNAMELEN];
    strcpy((node_acls)[0],"iqn.1991-05.com.microsoft:ibm-t410s");
   // strcpy((node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy((node_acls)[2],"iqn.1994-05.com.redhat:a4bf13a296d");
    int number = 3;
    iscsi_set_initiators(wwn,tag,node_acls,number);
    show_targetcli();
    free_all();


/* testcase 38
*set acls initiator list
* 
*
* @method input number_38 smaller than the number of number_38
*  
* @result established the target with the number_38 of acls give
*/
    iscsi_del_all_targets();

    init_sobj();

    target = (iscsitarget_t*)malloc(sizeof(iscsitarget_t));
    strcpy(target->chap_mutual_password, "567899876556");
    strcpy(target->chap_mutual_userid, "iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(target->chap_password, "123455432112");
    strcpy(target->chap_userid, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");
    target->enable = 1;
    target->tag = 1;
    target->node_acls_num = 0;
    strcpy((target->node_acls)[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy((target->node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");

    init_portal();
    init_para();
    init_attr();

    printf("Testcase38\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    char wwn_38[] = "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4";
    int tag_38 = 1;
    char node_acls_38[3][MAXNAMELEN];
    strcpy(node_acls_38[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(node_acls_38[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(node_acls_38[2],"iqn.1994-05.com.redhat:a4bf13a296d");
    int number_38 = 2;
    iscsi_set_initiators(wwn_38,tag_38,node_acls_38,number_38);
    show_targetcli();
    free_all();

/* testcase 39
*set acls initiator list
* 
*
* @method input number_39 bigger than the number of number_39
*  
* @result established the target with the number_39 of acls give
*/
    iscsi_del_all_targets();

    init_sobj();

    target = (iscsitarget_t*)malloc(sizeof(iscsitarget_t));
    strcpy(target->chap_mutual_password, "567899876556");
    strcpy(target->chap_mutual_userid, "iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(target->chap_password, "123455432112");
    strcpy(target->chap_userid, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");
    target->enable = 1;
    target->tag = 1;
    target->node_acls_num = 0;
    strcpy((target->node_acls)[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy((target->node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");

    init_portal();
    init_para();
    init_attr();

    printf("Testcase39\n");
    iscsi_create_target(sobj, target);

    show_targetcli();
    char wwn_39[] = "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4";
    int tag_39 = 1;
    char node_acls_39[3][MAXNAMELEN];
    strcpy(node_acls_39[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(node_acls_39[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(node_acls_39[2],"iqn.1994-05.com.redhat:a4bf13a296d");
    int number_39 = 5;
    iscsi_set_initiators(wwn_39,tag_39,node_acls_39,number_39);
    show_targetcli();
    free_all();

/* testcase 40
*set and delete acls initiator list
* 
*
* @method input number_40 under zero
*  
* @result give the hint number should greater than zero
*
*/
    iscsi_del_all_targets();

    init_sobj();

    target = (iscsitarget_t*)malloc(sizeof(iscsitarget_t));
    strcpy(target->chap_mutual_password, "567899876556");
    strcpy(target->chap_mutual_userid, "iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(target->chap_password, "123455432112");
    strcpy(target->chap_userid, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");
    target->enable = 1;
    target->tag = 1;
    target->node_acls_num = 0;
    strcpy((target->node_acls)[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy((target->node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");

    init_portal();
    init_para();
    init_attr();

    printf("Testcase40\n");
    iscsi_create_target(sobj, target);
    show_targetcli();



    char wwn_40[] = "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4";
    int tag_40 = 1;
    char node_acls_40[3][MAXNAMELEN];
    strcpy(node_acls_40[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(node_acls_40[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(node_acls_40[2],"iqn.1994-05.com.redhat:a4bf13a296d");
    int number_40 = -1;
    iscsi_set_initiators(wwn_40,tag_40,node_acls_40,number_40);
    show_targetcli();

    iscsi_del_initiators(wwn_40,tag_40,node_acls_40,number_40);
    show_targetcli();


    free_all();

/* testcase 41
*set and delete acls initiator list
* 
*
* @method input number_41 greater than node_acls_number
*  
* @result running success delete all initiator
*
*/
    iscsi_del_all_targets();

    init_sobj();

    target = (iscsitarget_t*)malloc(sizeof(iscsitarget_t));
    strcpy(target->chap_mutual_password, "567899876556");
    strcpy(target->chap_mutual_userid, "iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(target->chap_password, "123455432112");
    strcpy(target->chap_userid, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");
    target->enable = 1;
    target->tag = 1;
    target->node_acls_num = 0;
    strcpy((target->node_acls)[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy((target->node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");

    init_portal();
    init_para();
    init_attr();

    printf("Testcase41\n");
    iscsi_create_target(sobj, target);
    show_targetcli();



    char wwn_41[] = "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4";
    int tag_41 = 1;
    char node_acls_41[3][MAXNAMELEN];
    strcpy(node_acls_41[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(node_acls_41[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(node_acls_41[2],"iqn.1994-05.com.redhat:a4bf13a296d");
    int number_41 = 10;
    iscsi_set_initiators(wwn_41,tag_41,node_acls_41,number_41);
    show_targetcli();

    iscsi_del_initiators(wwn_41,tag_41,node_acls_41,number_41);
    show_targetcli();


    free_all();

/* testcase 42
*set and delete acls initiator list
* 
*
* @method input delete initiator number smaller than set initiator number
*  
* @result delete the first number of del_init_num_42 initialtor
*
*/
    iscsi_del_all_targets();

    init_sobj();

    target = (iscsitarget_t*)malloc(sizeof(iscsitarget_t));
    strcpy(target->chap_mutual_password, "567899876556");
    strcpy(target->chap_mutual_userid, "iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(target->chap_password, "123455432112");
    strcpy(target->chap_userid, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");
    target->enable = 1;
    target->tag = 1;
    target->node_acls_num = 0;
    strcpy((target->node_acls)[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy((target->node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");

    init_portal();
    init_para();
    init_attr();

    printf("Testcase42\n");
    iscsi_create_target(sobj, target);
    show_targetcli();



    char wwn_42[] = "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4";
    int tag_42 = 1;
    char node_acls_42[3][MAXNAMELEN];
    strcpy(node_acls_42[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(node_acls_42[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(node_acls_42[2],"iqn.1994-05.com.redhat:a4bf13a296d");
    int number_42 = 4;
    iscsi_set_initiators(wwn_42,tag_42,node_acls_42,number_42);
    show_targetcli();
    int del_init_num_42 = 2;
    iscsi_del_initiators(wwn_42,tag_42,node_acls_42,del_init_num_42 );
    show_targetcli();


    free_all();

/* testcase 43
*set and delete acls initiator list
* 
*
* @method input delete initiator number greater than set initiator number
*  
* @result delete all the  initialtor
*
*/
    iscsi_del_all_targets();

    init_sobj();

    target = (iscsitarget_t*)malloc(sizeof(iscsitarget_t));
    strcpy(target->chap_mutual_password, "567899876556");
    strcpy(target->chap_mutual_userid, "iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(target->chap_password, "123455432112");
    strcpy(target->chap_userid, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");
    target->enable = 1;
    target->tag = 1;
    target->node_acls_num = 0;
    strcpy((target->node_acls)[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy((target->node_acls)[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(target->wwn, "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4");

    init_portal();
    init_para();
    init_attr();

    printf("Testcase43\n");
    iscsi_create_target(sobj, target);
    show_targetcli();



    char wwn_43[] = "iqn.2003-01.org.linux-iscsi.localhost.x8664:sn.e16787b68bb4";
    int tag_43 = 1;
    char node_acls_43[3][MAXNAMELEN];
    strcpy(node_acls_43[0],"iqn.1991-05.com.microsoft:ibm-t410s");
    strcpy(node_acls_43[1],"iqn.1994-05.com.redhat:a4bf13a296c");
    strcpy(node_acls_43[2],"iqn.1994-05.com.redhat:a4bf13a296d");
    int number_43 = 4;
    iscsi_set_initiators(wwn_43,tag_43,node_acls_43,number_43);
    show_targetcli();
    int del_init_num_43 = 10;
    iscsi_del_initiators(wwn_43,tag_43,node_acls_43,del_init_num_43 );
    show_targetcli();


   free_all();

    return 0;
}