std::string impl::check_requirements(const atf::tests::vars_map& metadata, const atf::tests::vars_map& config) { std::string failure_reason = ""; for (atf::tests::vars_map::const_iterator iter = metadata.begin(); failure_reason.empty() && iter != metadata.end(); iter++) { const std::string& name = (*iter).first; const std::string& value = (*iter).second; INV(!value.empty()); // Enforced by application/X-atf-tp parser. if (name == "require.arch") failure_reason = check_arch(value); else if (name == "require.config") failure_reason = check_config(value, config); else if (name == "require.machine") failure_reason = check_machine(value); else if (name == "require.progs") failure_reason = check_progs(value); else if (name == "require.user") failure_reason = check_user(value, config); else { // Unknown require.* properties are forbidden by the // application/X-atf-tp parser. INV(failure_reason.find("require.") != 0); } } return failure_reason; }
static inline int read_type_and_machine(struct elf_file *file) { struct ehdr *ehdr = &file->ehdr; int retval = 0; retval = read_be_half_words(file->stream, &ehdr->e_type, 2); if (retval != 0) { error(0, 0, "couldn't read type and machine."); return retval; } retval = check_type(ehdr); if (retval != 0) return retval; retval = check_machine(ehdr); if (retval != 0) return retval; return 0; }
int main (int argc, char **argv) { int ret; int c; FILE *pidfile; struct utsname sysinfo; machine_type machine; while ((c = getopt(argc, argv, "fdv")) != -1) { switch (c) { case 'f': console = 1; break; case 'd': debug = 1; console = 1; break; case 'v': printf("pommed v" M_VERSION " Apple laptops hotkeys handler\n"); printf("Copyright (C) 2006-2011 Julien BLACHE <*****@*****.**>\n"); exit(0); break; default: usage(); exit(1); break; } } if (geteuid() != 0) { logmsg(LOG_ERR, "pommed needs root privileges to operate"); exit(1); } if (!console) { openlog("pommed", LOG_PID, LOG_DAEMON); } logmsg(LOG_INFO, "pommed v" M_VERSION " Apple laptops hotkeys handler"); logmsg(LOG_INFO, "Copyright (C) 2006-2011 Julien BLACHE <*****@*****.**>"); /* Load our configuration */ ret = config_load(); if (ret < 0) { exit(1); } /* Identify the machine we're running on */ machine = check_machine(); switch (machine) { case MACHINE_MAC_UNKNOWN: logmsg(LOG_ERR, "Unknown Apple machine"); exit(1); break; case MACHINE_UNKNOWN: logmsg(LOG_ERR, "Unknown non-Apple machine"); exit(1); break; case MACHINE_ERROR: exit(1); break; default: if (machine < MACHINE_LAST) { #ifdef __powerpc__ mops = &pb_mops[machine]; #else mops = &mb_mops[machine]; #endif /* __powerpc__ */ } break; } /* Runtime sanity check: catch errors in the mb_mops and pb_mops arrays */ if (mops->type != machine) { logmsg(LOG_ERR, "machine_ops mismatch: expected %d, found %d", machine, mops->type); exit(1); } if (debug) { ret = uname(&sysinfo); if (ret < 0) logmsg(LOG_ERR, "uname() failed: %s", strerror(errno)); else logdebug("System: %s %s %s\n", sysinfo.sysname, sysinfo.release, sysinfo.machine); } ret = evloop_init(); if (ret < 0) { logmsg(LOG_ERR, "Event loop initialization failed"); exit (1); } ret = mops->lcd_backlight_probe(); if (ret < 0) { logmsg(LOG_ERR, "LCD backlight probe failed, check debug output"); exit(1); } ret = evdev_init(); if (ret < 1) { logmsg(LOG_ERR, "No suitable event devices found"); exit(1); } kbd_backlight_init(); ret = audio_init(); if (ret < 0) { logmsg(LOG_WARNING, "Audio initialization failed, audio support disabled"); } ret = mbpdbus_init(); if (ret < 0) { logmsg(LOG_WARNING, "Could not connect to DBus system bus"); } power_init(); if (!console) { /* * Detach from the console */ if (daemon(0, 0) != 0) { logmsg(LOG_ERR, "daemon() failed: %s", strerror(errno)); evdev_cleanup(); exit(1); } } pidfile = fopen(PIDFILE, "w"); if (pidfile == NULL) { logmsg(LOG_WARNING, "Could not open pidfile %s: %s", PIDFILE, strerror(errno)); evdev_cleanup(); exit(1); } fprintf(pidfile, "%d\n", getpid()); fclose(pidfile); /* Spawn the beep thread */ beep_init(); signal(SIGINT, sig_int_term_handler); signal(SIGTERM, sig_int_term_handler); do { ret = evloop_iteration(); } while (ret >= 0); evdev_cleanup(); beep_cleanup(); mbpdbus_cleanup(); kbd_backlight_cleanup(); power_cleanup(); evloop_cleanup(); config_cleanup(); logmsg(LOG_INFO, "Exiting"); if (!console) closelog(); unlink(PIDFILE); return 0; }
extern void import_cnfg_ildg(char *in) { int my_rank,np[4],n,ie,tag,status,prec=0; int i,l,ix,iy,iz,it,ixx; n_uint64_t read_bytes,nbytes=0; double plaq1,eps; MPI_Status stat; LimeReader *reader=NULL; FILE *fin; char lime_type_target[100]="ildg-binary-data"; char *lime_type; MPI_Comm_rank(MPI_COMM_WORLD,&my_rank); /* allocate IO-buffers */ if (ubuf==NULL) alloc_ubuf_ildg(my_rank); error(pud[VOLUME/2][0]==NULL,1,"import_cnfg [archive_ildg.c]", "Double-precision gauge field is not allocated"); ie=check_machine(); if (my_rank==0) { fin=fopen(in,"rb"); error_root(fin==NULL,1,"import_cnfg [archive_ildg.c]", "Unable to open input file"); reader=limeCreateReader(fin); error( reader == (LimeReader *)NULL ,1,"import_cnfg [archive_ildg.c]", "Unable to open LimeReader"); nbytes = (n_uint64_t)0; /* set the file-pointer to the beginning of the "ildg-binary-data" tag * in the LIME file */ while( (status = limeReaderNextRecord(reader)) != LIME_EOF ){ nbytes = limeReaderBytes(reader); lime_type = limeReaderType(reader); error((status!=LIME_SUCCESS),1,"import_cnfg [archive_ildg.c]", "limeReaderNextRecord returned status %d and LIME_SUCCESS %d\n", status,LIME_SUCCESS); if (strcmp(lime_type,lime_type_target) != 0) continue; break; } /* Decide whether the gauge file is stored in single or * double precision format */ if ((int)nbytes==8*VOLUME*NPROC*3*3*4*2){ prec=8; message("ILDG-file contains double precision gauge field\n"); } else if ((int)nbytes==4*VOLUME*NPROC*3*3*4*2){ prec=4; message("ILDG-file contains single precision gauge field\n"); } else error(1!=0,1,"import_cnfg [archive_ildg]", "Lattice geometry doesn't match size of gauge field %d %d\n"); } /* Now read the gauge file in steps of 4 SU(3) matrices */ for (it=0;it<N0;it++){ for (iz=0;iz<N3;iz++){ for (iy=0;iy<N2;iy++){ for (ix=0;ix<N1;ix++){ if(my_rank==0){ if(prec==8){ read_bytes = (n_uint64_t)(4*18*sizeof(double)); status = limeReaderReadData((double *)vbuf,&read_bytes, reader); bswap_double(4*18,(double *)(vbuf));/* ILDG always big endian */ } else if(prec==4){ read_bytes = (n_uint64_t)(4*18*sizeof(float)); status = limeReaderReadData((void *)vbuf_s,&read_bytes, reader); bswap_float(4*18,(float *)(vbuf_s)); /* ILDG always big endian */ for (i=0;i<4;i++) su3_copy_singletodouble((vbuf_s+i),(vbuf+i)); } } np[0]=it; np[1]=ix; np[2]=iy; np[3]=iz; n=ipr_global(np); MPI_Barrier(MPI_COMM_WORLD); if (n>0) { tag=mpi_tag(); if (my_rank==0) MPI_Send((double*)(vbuf),4*18,MPI_DOUBLE,n,tag, MPI_COMM_WORLD); if (my_rank==n) MPI_Recv((double*)(ubuf),4*18,MPI_DOUBLE,0,tag, MPI_COMM_WORLD,&stat); } else if (my_rank==0) for (l=0;l<(4);l++) ubuf[l]=vbuf[l]; ixx = ((iy%L2)*L3 + (ix%L1)*L3*L2 + (it%L0)*L1*L2*L3); if (my_rank==n) set_links_ildg(ixx,iz); } } } } plaq1=plaq_sum_dble()/(double)(6*NPROC*VOLUME); message("Plaquette %f\n",plaq1); message("Plaquette/3 %f\n",plaq1/3); message("Please check consistency of average plaquette by hand\n"); eps=sqrt((double)(6*NPROC*VOLUME))*DBL_EPSILON; }