FILE * popen(char *cmd, char *mode) { int p[2]; int myside, hisside, pid; int i, ind; for (ind = 0; ind < MAXFORKS; ind++) if (the_fork[ind].pid == 0) break; if (ind == MAXFORKS) return NULL; if(pipe(p) < 0) return NULL; myside = tst(p[WTR], p[RDR]); hisside = tst(p[RDR], p[WTR]); switch (pid = fork()) { case -1: return NULL; case 0: /* myside and hisside reverse roles in child */ close(myside); dup2(hisside, tst(0, 1)); for (i=NSYSFILE; i<FOPEN_MAX; i++) close(i); execl("/bin/ape/sh", "sh", "-c", cmd, NULL); _exit(1); default: the_fork[ind].pid = pid; the_fork[ind].fd = myside; the_fork[ind].done = 0; close(hisside); return(fdopen(myside, mode)); } }
int main() { /* * Init. */ RTTEST hTest; int rc; if ( RT_FAILURE(rc = RTR3InitExeNoArguments(0)) || RT_FAILURE(rc = RTTestCreate("tstVMMR0CallHost-1", &hTest))) { RTStrmPrintf(g_pStdErr, "tstVMMR0CallHost-1: Fatal error during init: %Rrc\n", rc); return 1; } RTTestBanner(hTest); g_Jmp.pvSavedStack = (RTR0PTR)RTTestGuardedAllocTail(hTest, VMM_STACK_SIZE); /* * Run two test with about 1000 long jumps each. */ RTTestSub(hTest, "Increasing stack usage"); tst(0, 7000, 1); RTTestSub(hTest, "Decreasing stack usage"); tst(7599, 0, -1); return RTTestSummaryAndDestroy(hTest); }
void NesCpuTranslator::mHandleInterrupts() { // code at the bottom does following job: // // if (interrupts & mNmiInterrupt) { // hwInterrupt(NmiVectorAddress); // interrupts &= ~mNmiInterrupt; // } else if (interrupts & mIrqInterrupt) { // if (!(mFlags & mIrqDisable)) { // hwInterrupt(IrqVectorAddress); // } // } // r0 - 6502.PC address of the next instruction Label exitInterruptCheck; Label irqPending; Label doInterrupt; __ ldr(r1, MemOperand(mDataBase, offsetof(NesCpuRecData,interrupts))); __ mov(r1, r1, SetCC); __ b(&exitInterruptCheck, eq); __ tst(r1, Operand(NesCpuBase::NmiInterrupt)); __ b(&irqPending, eq); // NMI is handled here // clear NMI flag __ bic(r1, r1, Operand(NesCpuBase::NmiInterrupt)); __ str(r1, MemOperand(mDataBase, offsetof(NesCpuRecData,interrupts))); __ mov(r1, Operand(NesCpuBase::NmiVectorAddress)); __ b(&doInterrupt); // irqPending: // IRQ is handled here // check if P.I is cleared __ bind(&irqPending); __ tst(mFlags, Operand(NesCpuBase::IrqDisable)); __ b(&exitInterruptCheck, ne); __ mov(r1, Operand(NesCpuBase::IrqVectorAddress)); // doInterrupt: __ bind(&doInterrupt); // interrupt occured - handle it mHwInterrupt(); // exitInterruptCheck: __ bind(&exitInterruptCheck); }
FILE * mypopen(char *cmd, char *mode) { #if defined(WIN32) /* HBB 20010312: Has its own implementation of popen(), which * is better suited to the platform than cscope's */ return (popen)(cmd, mode); #else int p[2]; pid_t *poptr; int myside, yourside; pid_t pid; if(pipe(p) < 0) return(NULL); myside = tst(p[WTR], p[RDR]); yourside = tst(p[RDR], p[WTR]); if((pid = fork()) == 0) { /* myside and yourside reverse roles in child */ int stdio; /* close all pipes from other popen's */ for (poptr = popen_pid; poptr < popen_pid+20; poptr++) { if(*poptr) (void) close(poptr - popen_pid); } stdio = tst(0, 1); close(myside); close(stdio); #if defined(HAVE_F_DUPFD) fcntl(yourside, F_DUPFD, stdio); #else dup2(yourside, stdio); #endif /* defined(HAVE_F_DUPFD) */ close(yourside); execlp(shell, mybasename(shell), "-c", cmd, (void *)0); _exit(1); } else if (pid > 0) #if defined(HAVE_SIGSTP) tstat = signal(SIGTSTP, SIG_DFL); #endif if(pid == -1) return(NULL); popen_pid[myside] = pid; (void) close(yourside); return(fdopen(myside, mode)); #endif /* DJGPP */ }
int main(int argc, char** argv) { logstdout = yes; loglevel = 2; // Sem* sem = new Sem(0x3da00001); // sem->p(); // printf("got lock\n"); // sleep(5); // sem->v(); // printf("freed lock\n"); cRetBuf b = tst(); printf("%s\n", *b); // initConnection(); // chkStatement2(); // exitConnection(); return 0; }
TEST(Item, serialization) { std::ostringstream data; ::boost::archive::binary_oarchive arch(data); Item tst((const char*)nullptr); Item items[] = { Item(2.0), Item(2), Item("the most fatal mistake"), //Item(array::object()), // Item(map::object()) }; for (auto& itm : items) { arch << itm; } // reading std::string string = data.str(); std::istringstream istr(string); boost::archive::binary_iarchive ia(istr); for (const auto& itm : items) { Item tmp; ia >> tmp; EXPECT_TRUE( itm.isEqual(tmp) ); } }
void set_tab_width(struct MyGadget *gd,int val) { BTabView *bt; WrkWindow *wi; button_width tb; if (wi = (WrkWindow *)gd->pt->Window()) { BAutolock tst(wi); if (bt = (BTabView *)((GadView *)gd->pt)->ChildAt(0)) { switch(val) { case 0: tb = B_WIDTH_FROM_WIDEST; break; case 1: tb = B_WIDTH_AS_USUAL; break; case 2: tb = B_WIDTH_FROM_LABEL; break; } bt->SetTabWidth(tb); bt->Invalidate(); gd->pt->Invalidate(); } } }
int main (int argc, char **argv) { YAZ_CHECK_INIT(argc, argv); YAZ_CHECK_LOG(); tst(); YAZ_CHECK_TERM; }
OopMapSet* Runtime1::generate_patching(StubAssembler* sasm, address target) { // make a frame and preserve the caller's caller-save registers OopMap* oop_map = save_live_registers(sasm); // call the runtime patching routine, returns non-zero if nmethod got deopted. int call_offset = __ call_RT(noreg, noreg, target); OopMapSet* oop_maps = new OopMapSet(); oop_maps->add_gc_map(call_offset, oop_map); // re-execute the patched instruction or, if the nmethod was deoptmized, return to the // deoptimization handler entry that will cause re-execution of the current bytecode DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob(); assert(deopt_blob != NULL, "deoptimization blob must have been created"); Label no_deopt; __ tst(O0); __ brx(Assembler::equal, false, Assembler::pt, no_deopt); __ delayed()->nop(); // return to the deoptimization handler entry for unpacking and rexecute // if we simply returned the we'd deopt as if any call we patched had just // returned. restore_live_registers(sasm); __ restore(); __ br(Assembler::always, false, Assembler::pt, deopt_blob->unpack_with_reexecution(), relocInfo::runtime_call_type); __ delayed()->nop(); __ bind(no_deopt); restore_live_registers(sasm); __ ret(); __ delayed()->restore(); return oop_maps; }
void InterpreterRuntime::SignatureHandlerGenerator::pass_object() { Argument jni_arg(jni_offset(), false); Argument java_arg( offset(), true); Register Rtmp1 = O0; Register Rtmp2 = jni_arg.is_register() ? jni_arg.as_register() : O0; Register Rtmp3 = G3_scratch; // the handle for a receiver will never be null bool do_NULL_check = offset() != 0 || is_static(); Address h_arg = Address(Llocals, Interpreter::local_offset_in_bytes(offset())); __ ld_ptr(h_arg, Rtmp1); if (!do_NULL_check) { __ add(h_arg.base(), h_arg.disp(), Rtmp2); } else { if (Rtmp1 == Rtmp2) __ tst(Rtmp1); else __ addcc(G0, Rtmp1, Rtmp2); // optimize mov/test pair Label L; __ brx(Assembler::notZero, true, Assembler::pt, L); __ delayed()->add(h_arg.base(), h_arg.disp(), Rtmp2); __ bind(L); } __ store_ptr_argument(Rtmp2, jni_arg); // this is often a no-op }
int main() { test tst("this", 1); print(tst); test2 tst2("new"); print(tst2); }
void ReachingDefAna::ComputeDestInstList(){ for( list<BasicBlock*>::iterator it = pr->get_begin(), end = pr->get_end(); it != end; ++it){ for( list<instruction*>::iterator instIt = (*it)->get_begin_inst(), instEnd = (*it)->get_end_inst(); instIt != instEnd; ++instIt){ if( isDefInst((*instIt)->get_opcodeno())){ dIList[(*instIt)->get_destination_operand()].push_back(*instIt); } } } int bitnumber = 0; for(map<operand*,list<instruction*> >::iterator it = dIList.begin(),end=dIList.end(); it != end; ++it){ list<instruction*> tlist = it->second; DestTable[(it->first)].push_back(tlist.size());//Total no. of definitions DestTable[(it->first)].push_back(bitnumber);//start bit no. for(list<instruction*>::iterator it = tlist.begin(), end = tlist.end(); it != end; ++it){ instBitTable[*it] = bitnumber; bitInstTable[bitnumber] = *it; ++bitnumber; } DestTable[(it->first)].push_back(bitnumber-1);//end bit no. } //Initialize cout<<"##Initialization\n"; for( list<BasicBlock*>::iterator it = pr->get_begin(), end = pr->get_end(); it != end; ++it){ (*it)->bitResize(bitnumber); (*it)->initBitToZero(bitnumber); printBB((*it)); } string tst("initialization"); createDotFile(tst); }
void tstRandX (void (*tst)(unsigned long x)) { int i; for (i = 0; i < 1000; ++i) { tst(rand()); } }
int main(int argc, char **argv) { YAZ_CHECK_INIT(argc, argv); #if YAZ_HAVE_XML2 LIBXML_TEST_VERSION; #endif tst(); YAZ_CHECK_TERM; }
void RT_IndicationProvider::_checkOperationContext(const OperationContext& context, const String & funcName) { // // Test the filter query container // SubscriptionFilterQueryContainer qContainer = context.get(SubscriptionFilterQueryContainer::NAME); if (qContainer.getFilterQuery() == String::EMPTY) { PEGASUS_STD(cout) << funcName << "- empty filter query" << PEGASUS_STD(endl); throw CIMOperationFailedException(funcName + "- empty filter query"); } if (qContainer.getQueryLanguage() == String::EMPTY) { PEGASUS_STD(cout) << funcName << "- empty filter query lang" << PEGASUS_STD(endl); throw CIMOperationFailedException(funcName + "- empty filter query lang"); } CIMNamespaceName tst("root/SampleProvider"); if (!qContainer.getSourceNameSpace().equal(tst)) { PEGASUS_STD(cout) << funcName << "- incorrect source namespace" << PEGASUS_STD(endl); throw CIMOperationFailedException(funcName + "- incorrect source namespace"); } try { // // Try to parse the filter query from the filter query container // CIMOMHandleQueryContext ctx(qContainer.getSourceNameSpace(), _cimom); QueryExpression qe(qContainer.getQueryLanguage(), qContainer.getFilterQuery(), ctx); // Exercise the QueryExpression...this will cause repository access through // the CIMOMHandleQueryContext. qe.validate(); } catch (Exception & e) { PEGASUS_STD(cout) << funcName << "- parse error: " << e.getMessage() << PEGASUS_STD(endl); throw CIMOperationFailedException(funcName + "- parse error: " + e.getMessage()); } // // Test the filter condition container. // Note: since this only contains the WHERE clause, the condition could be empty (and will // be for some testcases) // SubscriptionFilterConditionContainer cContainer = context.get(SubscriptionFilterConditionContainer::NAME); if (cContainer.getQueryLanguage() == String::EMPTY) { PEGASUS_STD(cout) << funcName << "- empty filter condition lang" << PEGASUS_STD(endl); throw CIMOperationFailedException(funcName + "- empty filter condition lang"); } }
bool DNSList::readConfFile() { QFile file(dnslist_conf_file); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { qDebug()<<"no file"; return false; } QTextStream tst(&file); QString line; QStringList fields; while(!tst.atEnd()) { SDNSEntry entry; line = tst.readLine().trimmed(); qDebug()<<line; //Skip empty lines if (!line.length()) continue; //Skip comments if (line.indexOf("#") == 0) continue; fields = line.split(";"); if (fields.size() < 1) continue; //Read fields entry.mIP = fields[0].trimmed(); if (fields.size()>1) { entry.mProvider = fields[1].trimmed(); } if (fields.size()>2) { entry.mLocation = fields[2].trimmed(); } //check type of IP address if (trueos::Utils::validateIPV4(entry.mIP)) { servers_v4.push_back(entry); } else if (trueos::Utils::validateIPV6(entry.mIP)) { servers_v6.push_back(entry); } }//read all file lines return true; }
static void getword(int first, int (*tst)(int)) { int i=0; char c; yytext_ltl2ba[i++]= (char ) first; while (tst(c = tl_Getchar())) yytext_ltl2ba[i++] = c; yytext_ltl2ba[i] = '\0'; tl_UnGetchar(); }
static void getword(int first, int (*tst)(int),int *cnt, size_t hasuform, char *uform, Miscellaneous *miscell) { int i=0; char c; miscell->yytext[i++]= (char ) first; while (tst(c = tl_Getchar(cnt, hasuform, uform))) miscell->yytext[i++] = c; miscell->yytext[i] = '\0'; tl_UnGetchar(cnt); }
int main(int argc, char **argv) { time_t t; char buf[BUFSIZ]; time(&t); memset(buf, 0x55, sizeof buf); TIM_format(t, buf); printf("scan = %d <%s>\n", TIM_parse(buf), buf); /* Examples from RFC2616 section 3.3.1 */ tst("Sun, 06 Nov 1994 08:49:37 GMT", 784111777); tst("Sunday, 06-Nov-94 08:49:37 GMT", 784111777); tst("Sun Nov 6 08:49:37 1994", 784111777); tst_delta(); return (0); }
int rand_regression_test(size_t iter, size_t keys, const std::string name, TL tl) { // Sane defaults. size_t n = iter; size_t m = keys; size_t sd = 0; // 0 = time-determined arbitrary double tp = 0.2; double ip = 0.6; double dp = 0.1; double ep = 0.2; double cp = 0.001; double mp = 1; bool disp = false; // show progress try { detail::verify_params(sd, n, m, tp, ip, dp, ep, cp, mp, disp); } catch(__gnu_pbds::test::illegal_input_error&) { detail::usage(name); return -1; } catch(...) { return -2; }; xml_test_rand_regression_formatter* p_fmt = NULL; if (sd == 0) sd = twister_rand_gen::get_time_determined_seed(); if (disp) p_fmt = new xml_test_rand_regression_formatter(sd, n, m, tp, ip, dp, ep, cp, mp); try { detail::rand_reg_test tst(sd, n, m, tp, ip, dp, ep, cp, mp, disp); __gnu_cxx::typelist::apply(tst, tl); } catch(...) { std::cerr << "Test failed with seed " << sd << std::endl; if (disp) delete p_fmt; return -1; } if (disp) delete p_fmt; return 0; }
GV1(C,t1) { I h=m,i,c[9]; DO(h+1,c[i]=0); if(!n)R; for(;;) { for(n=c[i=h];i--;n=n*d[i]+c[i]); r=tst(t,(I *)r,1,(I *)(w+Tt(t,n)),v,u); for(i=h;++c[i]==d[i];)if(i)c[i--]=0;else R; } }
static void getword(int first, int (*tst)(int)) { int i=0, c; yytext[i++]= (char) first; while (tst(c = Getchar())) { yytext[i++] = (char) c; if (c == '\\') { c = Getchar(); yytext[i++] = (char) c; /* no tst */ } } yytext[i] = '\0'; Ungetch(c); }
static void alltst (void) { mpfr_exp_t emin, emax; ext = 0; tst (); underflow_up (); overflow_inv (); emin = mpfr_get_emin (); emax = mpfr_get_emax (); set_emin (MPFR_EMIN_MIN); set_emax (MPFR_EMAX_MAX); if (mpfr_get_emin () != emin || mpfr_get_emax () != emax) { ext = 1; tst (); underflow_up (); overflow_inv (); set_emin (emin); set_emax (emax); } }
void NBLoadedTLDef::collectLinks() { myControlledLinks.clear(); // build the list of links which are controled by the traffic light for (EdgeVector::iterator i = myIncomingEdges.begin(); i != myIncomingEdges.end(); i++) { NBEdge* incoming = *i; unsigned int noLanes = incoming->getNumLanes(); for (unsigned int j = 0; j < noLanes; j++) { std::vector<NBEdge::Connection> elv = incoming->getConnectionsFromLane(j); for (std::vector<NBEdge::Connection>::iterator k = elv.begin(); k != elv.end(); k++) { NBEdge::Connection el = *k; if (el.toEdge != 0) { myControlledLinks.push_back(NBConnection(incoming, j, el.toEdge, el.toLane)); } } } } // assign tl-indices to myControlledLinks unsigned int pos = 0; for (SignalGroupCont::const_iterator m = mySignalGroups.begin(); m != mySignalGroups.end(); m++) { SignalGroup* group = (*m).second; unsigned int linkNo = group->getLinkNo(); for (unsigned int j = 0; j < linkNo; j++) { const NBConnection& conn = group->getConnection(j); assert(conn.getFromLane() < 0 || (int) conn.getFrom()->getNumLanes() > conn.getFromLane()); NBConnection tst(conn); tst.setTLIndex(pos); if (tst.check(*myEdgeCont)) { if (tst.getFrom()->mayBeTLSControlled(tst.getFromLane(), tst.getTo(), tst.getToLane())) { for (NBConnectionVector::iterator it = myControlledLinks.begin(); it != myControlledLinks.end(); it++) { NBConnection& c = *it; if (c.getTLIndex() == NBConnection::InvalidTlIndex && tst.getFrom() == c.getFrom() && tst.getTo() == c.getTo() && (tst.getFromLane() < 0 || tst.getFromLane() == c.getFromLane()) && (tst.getToLane() < 0 || tst.getToLane() == c.getToLane())) { c.setTLIndex(pos); } } //std::cout << getID() << " group=" << (*m).first << " tst=" << tst << "\n"; pos++; } } else { WRITE_WARNING("Could not set signal on connection (signal: " + getID() + ", group: " + group->getID() + ")"); } } } }
int test_vexec() { std::cerr << "vexec"; std::string s("echo test;"); std::string tst("test\n"); std::string res = tools::vexec(s,0); if (res != tst) { std::cerr << "Result of vexec(" << res << ") doesn`t equal to test data(" << tst << ")" << std::endl; return 1; } std::cerr << "."; std::cerr << "Ok" << std::endl; return 0; }
int main() { xc_error_sethandler(xc_exception_handler, "exception handler"); tst(IDEAL(100),IDEAL(100)); tst(IDEAL(100),IDEAL(1000)); tst(IDEAL(100),IDEAL(10000)); tst(IDEAL(10000),IDEAL(1000)); tst(IDEAL(10000),IDEAL(10000)); tst(IDEAL(10000),IDEAL(100000)); return 0; }
void Runtime1::generate_handle_exception(StubAssembler* sasm, OopMapSet* oop_maps, OopMap* oop_map, bool) { Label no_deopt; Label no_handler; __ verify_not_null_oop(Oexception); // save the exception and issuing pc in the thread __ st_ptr(Oexception, G2_thread, in_bytes(JavaThread::exception_oop_offset())); __ st_ptr(Oissuing_pc, G2_thread, in_bytes(JavaThread::exception_pc_offset())); // save the real return address and use the throwing pc as the return address to lookup (has bci & oop map) __ mov(I7, L0); __ mov(Oissuing_pc, I7); __ sub(I7, frame::pc_return_offset, I7); int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, exception_handler_for_pc)); // Note: if nmethod has been deoptimized then regardless of // whether it had a handler or not we will deoptimize // by entering the deopt blob with a pending exception. __ tst(O0); __ br(Assembler::zero, false, Assembler::pn, no_handler); __ delayed()->nop(); // restore the registers that were saved at the beginning and jump to the exception handler. restore_live_registers(sasm); __ jmp(O0, 0); __ delayed()->restore(); __ bind(no_handler); __ mov(L0, I7); // restore return address // restore exception oop __ ld_ptr(G2_thread, in_bytes(JavaThread::exception_oop_offset()), Oexception->after_save()); __ st_ptr(G0, G2_thread, in_bytes(JavaThread::exception_oop_offset())); __ restore(); AddressLiteral exc(Runtime1::entry_for(Runtime1::unwind_exception_id)); __ jump_to(exc, G4); __ delayed()->nop(); oop_maps->add_gc_map(call_offset, oop_map); }
void set_tab_select(struct MyGadget *gd,int tb) { BTabView *bt; WrkWindow *wi; if (wi = (WrkWindow *)gd->pt->Window()) { BAutolock tst(wi); if (bt = (BTabView *)((GadView *)gd->pt)->ChildAt(0)) { bt->Select(tb); gd->pt->Invalidate(); } } }
static void tl_getword(int first, int (*tst)(int)) { int i=0; int c; yytext[i++] = (char ) first; c = tl_Getchar(); while (c != -1 && tst(c)) { yytext[i++] = (char) c; c = tl_Getchar(); } /* while (tst(c = tl_Getchar())) * yytext[i++] = c; */ yytext[i] = '\0'; tl_UnGetchar(); }
void removeNoLog(string pat){ gSystem->Exec(Form("ls -d %s > z_log.lst",pat.c_str())); ifstream fin("z_log.lst"); string data; while(fin>>data){ data+="/log/log.out"; ifstream tst(data.c_str(),ios::in); if(!tst.good()){ TString file(data.c_str()); file.Remove(file.First('/'),file.Length()); gSystem->Exec(Form("rm -rf %s",file.Data())); cout<<data<<" removing folder "<<file.Data()<<endl; } else tst.close(); } fin.close(); gSystem->Exec("rm -rf z_log.lst"); }