TEST(logcat, logrotate_suffix) { static const char tmp_out_dir_form[] = "/data/local/tmp/logcat.logrotate.XXXXXX"; char tmp_out_dir[sizeof(tmp_out_dir_form)]; ASSERT_TRUE(NULL != mkdtemp(strcpy(tmp_out_dir, tmp_out_dir_form))); static const char logcat_cmd[] = "logcat -b radio -b events -b system -b main" " -d -f %s/log.txt -n 10 -r 1"; char command[sizeof(tmp_out_dir) + sizeof(logcat_cmd)]; snprintf(command, sizeof(command), logcat_cmd, tmp_out_dir); int ret; EXPECT_FALSE(IsFalse(ret = system(command), command)); if (!ret) { snprintf(command, sizeof(command), "ls %s 2>/dev/null", tmp_out_dir); FILE *fp; EXPECT_TRUE(NULL != (fp = popen(command, "r"))); char buffer[BIG_BUFFER]; int log_file_count = 0; while (fgets(buffer, sizeof(buffer), fp)) { static const char rotated_log_filename_prefix[] = "log.txt."; static const size_t rotated_log_filename_prefix_len = strlen(rotated_log_filename_prefix); static const char log_filename[] = "log.txt"; if (!strncmp(buffer, rotated_log_filename_prefix, rotated_log_filename_prefix_len)) { // Rotated file should have form log.txt.## char* rotated_log_filename_suffix = buffer + rotated_log_filename_prefix_len; char* endptr; const long int suffix_value = strtol(rotated_log_filename_suffix, &endptr, 10); EXPECT_EQ(rotated_log_filename_suffix + 2, endptr); EXPECT_LE(suffix_value, 10); EXPECT_GT(suffix_value, 0); ++log_file_count; continue; } if (!strncmp(buffer, log_filename, strlen(log_filename))) { ++log_file_count; continue; } fprintf(stderr, "ERROR: Unexpected file: %s", buffer); ADD_FAILURE(); } pclose(fp); EXPECT_EQ(11, log_file_count); } snprintf(command, sizeof(command), "rm -rf %s", tmp_out_dir); EXPECT_FALSE(IsFalse(system(command), command)); }
static int logrotate_count_id(const char *logcat_cmd, const char *tmp_out_dir) { static const char log_filename[] = "log.txt"; char command[strlen(tmp_out_dir) + strlen(logcat_cmd) + strlen(log_filename) + 32]; snprintf(command, sizeof(command), logcat_cmd, tmp_out_dir, log_filename); int ret; EXPECT_FALSE(IsFalse(ret = system(command), command)); if (ret) { return -1; } std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(tmp_out_dir), closedir); EXPECT_NE(nullptr, dir); if (!dir) { return -1; } struct dirent *entry; int count = 0; while ((entry = readdir(dir.get()))) { if (strncmp(entry->d_name, log_filename, sizeof(log_filename) - 1)) { continue; } ++count; } return count; }
bool YacasPatternPredicateBase::CheckPredicates(LispEnvironment& aEnvironment) { const std::size_t n = iPredicates.size(); for (std::size_t i = 0; i < n; ++i) { LispPtr pred; aEnvironment.iEvaluator->Eval(aEnvironment, pred, iPredicates[i]); if (IsFalse(aEnvironment, pred)) { return false; } // If the result is not False, it should be True, else probably something is wrong (the expression returned unevaluated) bool isTrue = IsTrue(aEnvironment, pred); if (!isTrue) { #define LIM_AL 60 LispString strout; aEnvironment.iErrorOutput << "The predicate\n\t"; PrintExpression(strout, iPredicates[i], aEnvironment, LIM_AL); aEnvironment.iErrorOutput << strout; aEnvironment.iErrorOutput << "\nevaluated to\n\t"; PrintExpression(strout, pred, aEnvironment, LIM_AL); aEnvironment.iErrorOutput << strout << '\n'; ShowStack(aEnvironment); throw LispErrMaxRecurseDepthReached(); } } return true; }
std::string BooleanValue::ToString() const { if (IsTrue()) return "true"; if (IsFalse()) return "false"; return "boolean_null"; }
TEST_F(BooleanValueTests, BasicTest) { auto valTrue = type::ValueFactory::GetBooleanValue(true); auto valFalse = type::ValueFactory::GetBooleanValue(false); auto valNull = type::ValueFactory::GetNullValueByType(type::TypeId::BOOLEAN); EXPECT_TRUE(valTrue.IsTrue()); EXPECT_FALSE(valTrue.IsFalse()); EXPECT_FALSE(valTrue.IsNull()); EXPECT_FALSE(valFalse.IsTrue()); EXPECT_TRUE(valFalse.IsFalse()); EXPECT_FALSE(valFalse.IsNull()); EXPECT_FALSE(valNull.IsTrue()); EXPECT_FALSE(valNull.IsFalse()); EXPECT_TRUE(valNull.IsNull()); }
TEST(logcat, logrotate) { static const char form[] = "/data/local/tmp/logcat.logrotate.XXXXXX"; char buf[sizeof(form)]; ASSERT_TRUE(NULL != mkdtemp(strcpy(buf, form))); static const char comm[] = "logcat -b radio -b events -b system -b main" " -d -f %s/log.txt -n 7 -r 1"; char command[sizeof(buf) + sizeof(comm)]; snprintf(command, sizeof(command), comm, buf); int ret; EXPECT_FALSE(IsFalse(ret = system(command), command)); if (!ret) { snprintf(command, sizeof(command), "ls -s %s 2>/dev/null", buf); FILE *fp; EXPECT_TRUE(NULL != (fp = popen(command, "r"))); if (fp) { char buffer[BIG_BUFFER]; int count = 0; while (fgets(buffer, sizeof(buffer), fp)) { static const char total[] = "total "; int num; char c; if ((2 == sscanf(buffer, "%d log.tx%c", &num, &c)) && (num <= 40)) { ++count; } else if (strncmp(buffer, total, sizeof(total) - 1)) { fprintf(stderr, "WARNING: Parse error: %s", buffer); } } pclose(fp); if ((count != 7) && (count != 8)) { fprintf(stderr, "count=%d\n", count); } EXPECT_TRUE(count == 7 || count == 8); } } snprintf(command, sizeof(command), "rm -rf %s", buf); EXPECT_FALSE(IsFalse(system(command), command)); }
TEST_F(JSDeviceTest, isNotSecureCapable) { ZDevice zDevice{annunceAllOff}; V8_SETUP EXPECT_CALL(*zDevices.get(), exists(extAddress)).WillOnce(Return(true)); EXPECT_CALL(*zDevices.get(), getDevice(extAddress)).WillOnce(Return(&zDevice)); v8::Local<v8::Value> result = runScript(creatingZDeviceScript + "a.isSecureCapable();"); ASSERT_THAT(result.IsEmpty(), false); ASSERT_THAT(result->IsBoolean(), true); ASSERT_THAT(result, IsFalse()); }
static void readDIMACSTest() { Minisat::Formula formula; std::stringstream ss{ResourceFile::get("minisat/satisfiable.txt")->data()}; AssertThat(formula.readDimacs(ss), IsTrue()); Minisat::Model model; bool satisfiable = formula.solve(model); AssertThat(satisfiable, IsTrue()); formula.addClause(std::vector<int>{3}); satisfiable = formula.solve(model); AssertThat(satisfiable, IsFalse()); }
static void nonsatisfiableTest() { Minisat::Formula F; Minisat::Model model; F.addClause(std::vector<int>{1, 2}); F.addClause(std::vector<int>{1, -2, 3}); F.addClause(std::vector<int>{-1, 2}); F.addClause(std::vector<int>{-1, -2}); F.addClause(std::vector<int>{-3}); bool satisfiable = F.solve(model); AssertThat(satisfiable, IsFalse()); }
bool QObjectProxy::eventFilter( QObject * watched, QEvent * event ) { int type = event->type(); if( type == ScMethodCallType ) { ScMethodCallEvent* mce = static_cast<ScMethodCallEvent*>( event ); qscDebugMsg("executing SC method: %s\n", mce->method->name ); scMethodCallEvent( mce ); return true; } else { EventHandlerData eh = eventHandlers.value( type, EventHandlerData() ); if( eh.type == type ) { PyrSymbol *symMethod = eh.method; qscDebugMsg("catching event %i with handler '%s'\n", type, symMethod->name ); InterpretEventFn interpreter = eh.interpretFn; QList<QVariant> args; if( interpreter ) { qscDebugMsg("got interpreter\n"); (this->*interpreter) ( event, args ); } if( eh.direct ) { qscDebugMsg("direct!\n"); PyrSlot result; QtCollider::execute( scObject, symMethod, args, &result ); if( IsNil( &result ) ) return false; else { if( IsFalse( &result ) ) event->ignore(); return true; } } else { qscDebugMsg("indirect\n"); ScMethodCallEvent *e = new ScMethodCallEvent( symMethod, args ); QApplication::postEvent( this, e ); } } return false; } }
TEST(logcat, logrotate_id) { static const char logcat_cmd[] = "logcat -b all -d -f %s/%s -n 32 -r 1 --id=test"; static const char logcat_short_cmd[] = "logcat -b all -t 10 -f %s/%s -n 32 -r 1 --id=test"; static const char tmp_out_dir_form[] = "/data/local/tmp/logcat.logrotate.XXXXXX"; static const char log_filename[] = "log.txt"; char tmp_out_dir[strlen(tmp_out_dir_form) + 1]; ASSERT_TRUE(NULL != mkdtemp(strcpy(tmp_out_dir, tmp_out_dir_form))); EXPECT_EQ(34, logrotate_count_id(logcat_cmd, tmp_out_dir)); EXPECT_EQ(34, logrotate_count_id(logcat_short_cmd, tmp_out_dir)); char id_file[strlen(tmp_out_dir_form) + strlen(log_filename) + 5]; snprintf(id_file, sizeof(id_file), "%s/%s.id", tmp_out_dir, log_filename); if (getuid() != 0) { chmod(id_file, 0); EXPECT_EQ(34, logrotate_count_id(logcat_short_cmd, tmp_out_dir)); } unlink(id_file); EXPECT_EQ(34, logrotate_count_id(logcat_short_cmd, tmp_out_dir)); FILE *fp = fopen(id_file, "w"); if (fp) { fprintf(fp, "not_a_test"); fclose(fp); } if (getuid() != 0) { chmod(id_file, 0); // API to preserve content even with signature change ASSERT_EQ(34, logrotate_count_id(logcat_short_cmd, tmp_out_dir)); chmod(id_file, 0600); } int new_signature; EXPECT_LE(2, (new_signature = logrotate_count_id(logcat_short_cmd, tmp_out_dir))); EXPECT_GT(34, new_signature); static const char cleanup_cmd[] = "rm -rf %s"; char command[strlen(cleanup_cmd) + strlen(tmp_out_dir_form)]; snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir); EXPECT_FALSE(IsFalse(system(command), command)); }
int Receive_RenderOptions(POVMSObjectPtr msg, POVMSObjectPtr result, int, void *) { POVMSAttribute attr; POVMSInt i; POVMSFloat f; POVMSBool b; int l = 0; if(Cooperate_Render_Flag != 1) return -1; if(gStartedStreamMessage == NULL) { if(POVMSObject_New(&gStartedStreamMessageData, kPOVMSType_WildCard) == kNoErr) gStartedStreamMessage = &gStartedStreamMessageData; } l = sizeof(unsigned long); if(POVMSObject_Get(msg, &attr, kPOVAttrib_PreviewRefCon) == kNoErr) { (void)POVMSAttr_Get(&attr, kPOVMSType_WildCard, (void *)(&opts.Preview_RefCon), &l); (void)POVMSAttr_Delete(&attr); } if(POVMSUtil_GetInt(msg, kPOVAttrib_WarningLevel, &i) == 0) opts.Warning_Level = i; if(POVMSUtil_GetInt(msg, kPOVAttrib_Height, &i) == 0) Frame.Screen_Height = i; if(POVMSUtil_GetInt(msg, kPOVAttrib_Width, &i) == 0) Frame.Screen_Width = i; if(POVMSUtil_GetFloat(msg, kPOVAttrib_StartColumn, &f) == 0) { if(f >= 0.0 && f < 1.0) { opts.First_Column = -1; opts.First_Column_Percent = f; } else opts.First_Column = (int)f; } if(POVMSUtil_GetFloat(msg, kPOVAttrib_EndColumn, &f) == 0) { if((f >= 0.0 && f < 1.0) || ((f >= 0.0 && f <= 1.0) && (opts.First_Column < 1))) { opts.Last_Column = -1; opts.Last_Column_Percent = f; } else opts.Last_Column = (int)f; } if(POVMSUtil_GetFloat(msg, kPOVAttrib_StartRow, &f) == 0) { if(f >= 0.0 && f < 1.0) { opts.First_Line = -1; opts.First_Line_Percent = f; } else opts.First_Line = (int)f; } if(POVMSUtil_GetFloat(msg, kPOVAttrib_EndRow, &f) == 0) { if((f >= 0.0 && f < 1.0) || ((f >= 0.0 && f <= 1.0) && (opts.First_Line < 1))) { opts.Last_Line = -1; opts.Last_Line_Percent = f; } else opts.Last_Line = (int)f; } if(POVMSUtil_GetBool(msg, kPOVAttrib_TestAbort, &b) == 0) { if(b == true) opts.Options |= EXITENABLE; else opts.Options &= ~EXITENABLE; } if(POVMSUtil_GetInt(msg, kPOVAttrib_TestAbortCount, &i) == 0) opts.Abort_Test_Counter = i; if(POVMSUtil_GetBool(msg, kPOVAttrib_ContinueTrace, &b) == 0) { if(b == true) opts.Options |= CONTINUE_TRACE; else opts.Options &= ~CONTINUE_TRACE; } l = FILE_NAME_LENGTH; (void)POVMSUtil_GetString(msg, kPOVAttrib_CreateIni, opts.Ini_Output_File_Name, &l); if(POVMSUtil_GetFloat(msg, kPOVAttrib_Clock, &f) == 0) opts.FrameSeq.Clock_Value = f; if(POVMSUtil_GetInt(msg, kPOVAttrib_InitialFrame, &i) == 0) opts.FrameSeq.InitialFrame = i; if(POVMSUtil_GetInt(msg, kPOVAttrib_FinalFrame, &i) == 0) opts.FrameSeq.FinalFrame = i; if(POVMSUtil_GetFloat(msg, kPOVAttrib_InitialClock, &f) == 0) opts.FrameSeq.InitialClock = f; if(POVMSUtil_GetFloat(msg, kPOVAttrib_FinalClock, &f) == 0) opts.FrameSeq.FinalClock = f; if(POVMSUtil_GetFloat(msg, kPOVAttrib_SubsetStartFrame, &f) == 0) { if(f > 0.0 && f < 1.0) opts.FrameSeq.SubsetStartPercent = f; else opts.FrameSeq.SubsetStartFrame = (int)f; } if(POVMSUtil_GetFloat(msg, kPOVAttrib_SubsetEndFrame, &f) == 0) { if(f > 0.0 && f < 1.0) opts.FrameSeq.SubsetEndPercent = f; else opts.FrameSeq.SubsetEndFrame = (int)f; } if(POVMSUtil_GetBool(msg, kPOVAttrib_CyclicAnimation, &b) == 0) { if(b == true) opts.Options |= CYCLIC_ANIMATION; else opts.Options &= ~CYCLIC_ANIMATION; } if(POVMSUtil_GetBool(msg, kPOVAttrib_FieldRender, &b) == 0) opts.FrameSeq.Field_Render_Flag = b; if(POVMSUtil_GetBool(msg, kPOVAttrib_OddField, &b) == 0) opts.FrameSeq.Odd_Field_Flag = b; if(POVMSUtil_GetBool(msg, kPOVAttrib_PauseWhenDone, &b) == 0) { if(b == true) opts.Options |= PROMPTEXIT; else opts.Options &= ~PROMPTEXIT; } if(POVMSUtil_GetBool(msg, kPOVAttrib_Verbose, &b) == 0) { if(b == true) opts.Options |= VERBOSE; else opts.Options &= ~VERBOSE; } if(POVMSUtil_GetBool(msg, kPOVAttrib_DrawVistas, &b) == 0) { if(b == true) opts.Options |= USE_VISTA_DRAW; else opts.Options &= ~USE_VISTA_DRAW; } if(POVMSUtil_GetBool(msg, kPOVAttrib_Display, &b) == 0) { if(b == true) opts.Options |= DISPLAY; else opts.Options &= ~DISPLAY; } if(POVMSUtil_GetInt(msg, kPOVAttrib_VideoMode, &i) == 0) opts.DisplayFormat = (char)toupper(i); if(POVMSUtil_GetInt(msg, kPOVAttrib_Palette, &i) == 0) opts.PaletteOption = (char)toupper(i); if(POVMSUtil_GetFloat(msg, kPOVAttrib_DisplayGamma, &f) == 0) { if(f > 0.0) opts.DisplayGamma = f; } if(POVMSUtil_GetInt(msg, kPOVAttrib_PreviewStartSize, &i) == 0) opts.PreviewGridSize_Start = i; if(POVMSUtil_GetInt(msg, kPOVAttrib_PreviewEndSize, &i) == 0) opts.PreviewGridSize_End = i; if(POVMSUtil_GetBool(msg, kPOVAttrib_OutputToFile, &b) == 0) { if(b == true) opts.Options |= DISKWRITE; else opts.Options &= ~DISKWRITE; } if(POVMSUtil_GetInt(msg, kPOVAttrib_OutputFileType, &i) == 0) opts.OutputFormat = (char)tolower(i); if(POVMSUtil_GetInt(msg, kPOVAttrib_Compression, &i) == 0) { if(opts.OutputFormat == 'j') { opts.OutputQuality = i; opts.OutputQuality = max(0, opts.OutputQuality); opts.OutputQuality = min(100, opts.OutputQuality); } } if(POVMSUtil_GetBool(msg, kPOVAttrib_OutputAlpha, &b) == 0) { if(b == true) opts.Options |= OUTPUT_ALPHA; else opts.Options &= ~OUTPUT_ALPHA; } if(POVMSUtil_GetInt(msg, kPOVAttrib_BitsPerColor, &i) == 0) { if(opts.OutputFormat != 'j') { opts.OutputQuality = i; opts.OutputQuality = max(5, opts.OutputQuality); opts.OutputQuality = min(16, opts.OutputQuality); } } l = FILE_NAME_LENGTH; if(POVMSUtil_GetString(msg, kPOVAttrib_OutputFile, opts.Output_File_Name, &l) == 0) { if(!strcmp(opts.Output_File_Name, "-") || !strcmp(opts.Output_File_Name, "stdout")) { strcpy(opts.Output_File_Name, "stdout"); opts.Options |= TO_STDOUT; } } l = FILE_NAME_LENGTH; opts.Ini_Output_File_Name[0] = '\0'; (void)POVMSUtil_GetString(msg, kPOVAttrib_CreateIni, opts.Ini_Output_File_Name, &l); #if PRECISION_TIMER_AVAILABLE if(POVMSUtil_GetBool(msg, kPOVAttrib_CreateHistogram, &b) == 0) opts.histogram_on = b; if(POVMSUtil_GetInt(msg, kPOVAttrib_HistogramFileType, &i) == 0) { char *def_ext = NULL; switch(i) { case 'C': case 'c': opts.histogram_type = CSV; opts.histogram_file_type = NO_FILE; // CSV has special handling in histogram output, so this is correct [trf] def_ext = ".csv"; break; case 'S': case 's': opts.histogram_type = SYS ; opts.histogram_file_type = SYS_FILE; def_ext = SYS_DEF_EXT; break ; case 'P' : case 'p' : opts.histogram_type = PPM; opts.histogram_file_type = PPM_FILE; def_ext = ".ppm"; break; case 'T': case 't': opts.histogram_type = TARGA; opts.histogram_file_type = TGA_FILE; def_ext = ".tga"; break; case 'N': case 'n': opts.histogram_type = PNG; opts.histogram_file_type = PNG_FILE; def_ext = ".png"; break; default: opts.histogram_type = TARGA; opts.histogram_file_type = TGA_FILE; Warning(0, "Unknown histogram output type '%c'.", (char)i); break ; } // Process the histogram file name now, if it hasn't // yet been specified, and in case it isn't set later. if (opts.histogram_on && (opts.Histogram_File_Name[0] == '\0') && (def_ext != NULL)) sprintf(opts.Histogram_File_Name, "histgram%s", def_ext); } l = FILE_NAME_LENGTH; if(POVMSUtil_GetString(msg, kPOVAttrib_HistogramFile, opts.Histogram_File_Name, &l) == 0) { if(opts.histogram_on && opts.Histogram_File_Name[0] == '\0') { char *def_ext = NULL; switch(opts.histogram_type) { case CSV: def_ext = ".csv"; break; case TARGA: def_ext = ".tga"; break; case PNG: def_ext = ".png"; break; case PPM: def_ext = ".ppm"; break; case SYS: def_ext = SYS_DEF_EXT; break; case NONE: def_ext = ""; break; /* To quiet warnings */ } sprintf(opts.Histogram_File_Name, "histgram%s", def_ext); } } if(POVMSUtil_GetInt(msg, kPOVAttrib_HistogramGridSizeX, &i) == 0) opts.histogram_x = i; if(POVMSUtil_GetInt(msg, kPOVAttrib_HistogramGridSizeY, &i) == 0) opts.histogram_y = i; #endif /* PRECISION_TIMER_AVAILABLE */ (void)SetCommandOption(msg, kPOVAttrib_PreSceneCommand, &opts.Shellouts[PRE_SCENE_SHL]); (void)SetCommandOption(msg, kPOVAttrib_PreFrameCommand, &opts.Shellouts[PRE_FRAME_SHL]); (void)SetCommandOption(msg, kPOVAttrib_PostSceneCommand, &opts.Shellouts[POST_SCENE_SHL]); (void)SetCommandOption(msg, kPOVAttrib_PostFrameCommand, &opts.Shellouts[POST_FRAME_SHL]); (void)SetCommandOption(msg, kPOVAttrib_UserAbortCommand, &opts.Shellouts[USER_ABORT_SHL]); (void)SetCommandOption(msg, kPOVAttrib_FatalErrorCommand, &opts.Shellouts[FATAL_SHL]); l = FILE_NAME_LENGTH; if(POVMSUtil_GetString(msg, kPOVAttrib_InputFile, opts.Input_File_Name, &l) == 0) { if(!strcmp(opts.Input_File_Name, "-") || !strcmp(opts.Input_File_Name, "stdin")) { strcpy (opts.Input_File_Name, "stdin"); opts.Options |= FROM_STDIN; } } if(POVMSObject_Get(msg, &attr, kPOVAttrib_LibraryPath) == 0) { int cnt = 0; if(POVMSAttrList_Count(&attr, &cnt) == 0) { POVMSAttribute item; int ii,iii; bool rem = false; for(ii = 1; ii <= cnt; ii++) { if(POVMSAttrList_GetNth(&attr, ii, &item) == 0) { l = 0; if(POVMSAttr_Size(&item, &l) == 0) { if(l > 0) { if(opts.Library_Path_Index >= MAX_LIBRARIES) Error ("Too many library directories specified."); opts.Library_Paths[opts.Library_Path_Index] = (char *)POV_MALLOC(l, "library paths"); if(POVMSAttr_Get(&item, kPOVMSType_CString, opts.Library_Paths[opts.Library_Path_Index], &l) == 0) rem = false; else rem = true; // remove path again if the same one already exists for(iii = 0; iii < opts.Library_Path_Index - 1; iii++) { if(strcmp(opts.Library_Paths[iii], opts.Library_Paths[opts.Library_Path_Index]) == 0) { rem = true; break; } } if(rem == true) { POV_FREE(opts.Library_Paths[opts.Library_Path_Index]); opts.Library_Paths[opts.Library_Path_Index] = NULL; } else opts.Library_Path_Index++; } } (void)POVMSAttr_Delete(&item); } } } (void)POVMSAttr_Delete(&attr); } if(POVMSUtil_GetFloat(msg, kPOVAttrib_Version, &f) == 0) opts.Language_Version = (int)(f * 100 + 0.5); (void)POVMSObject_Delete(gStartedStreamMessage); (void)POVMSObject_New(gStartedStreamMessage, kPOVMSType_WildCard); if(POVMSUtil_GetBool(msg, kPOVAttrib_AllConsole, &b) == 0) { (void)POVMSUtil_SetBool(gStartedStreamMessage, kPOVAttrib_AllConsole, b); (void)POVMSUtil_SetBool(gStartedStreamMessage, kPOVAttrib_DebugConsole, b); (void)POVMSUtil_SetBool(gStartedStreamMessage, kPOVAttrib_FatalConsole, b); (void)POVMSUtil_SetBool(gStartedStreamMessage, kPOVAttrib_RenderConsole, b); (void)POVMSUtil_SetBool(gStartedStreamMessage, kPOVAttrib_StatisticsConsole, b); (void)POVMSUtil_SetBool(gStartedStreamMessage, kPOVAttrib_WarningConsole, b); } if(POVMSUtil_GetBool(msg, kPOVAttrib_DebugConsole, &b) == 0) (void)POVMSUtil_SetBool(gStartedStreamMessage, kPOVAttrib_DebugConsole, b); if(POVMSUtil_GetBool(msg, kPOVAttrib_FatalConsole, &b) == 0) (void)POVMSUtil_SetBool(gStartedStreamMessage, kPOVAttrib_FatalConsole, b); if(POVMSUtil_GetBool(msg, kPOVAttrib_RenderConsole, &b) == 0) (void)POVMSUtil_SetBool(gStartedStreamMessage, kPOVAttrib_RenderConsole, b); if(POVMSUtil_GetBool(msg, kPOVAttrib_StatisticsConsole, &b) == 0) (void)POVMSUtil_SetBool(gStartedStreamMessage, kPOVAttrib_StatisticsConsole, b); if(POVMSUtil_GetBool(msg, kPOVAttrib_WarningConsole, &b) == 0) (void)POVMSUtil_SetBool(gStartedStreamMessage, kPOVAttrib_WarningConsole, b); for(i = 0; i < gStreamTypeUtilDataCount; i++) { l = 0; if(POVMSUtil_GetStringLength(msg, gStreamTypeUtilData[i], &l) == kNoErr) { char *str = (char *)POV_MALLOC(l, "stream name"); if(POVMSUtil_GetString(msg, gStreamTypeUtilData[i], str, &l) == kNoErr) { if(l > 1) { if(IsTrue(str) == true) (void)POVMSUtil_SetString(gStartedStreamMessage, gStreamTypeUtilData[i], gStreamDefaultFile[i]); else if(IsFalse(str) == false) (void)POVMSUtil_SetString(gStartedStreamMessage, gStreamTypeUtilData[i], str); } } POV_FREE(str); } } if(POVMSUtil_GetInt(msg, kPOVAttrib_Quality, &i) == 0) { opts.Quality = i; /* Emit a warning about the "radiosity" quality levels for * now. We can get rid of this some time in the future. */ if ((opts.Quality == 10) || (opts.Quality == 11)) { Warning(0, "Quality settings 10 and 11 are no longer valid."); opts.Quality = 9; } else if ((opts.Quality < 0) || (opts.Quality > 9)) Error("Illegal Quality setting."); opts.Quality_Flags = Quality_Values[opts.Quality]; } if(POVMSUtil_GetBool(msg, kPOVAttrib_Bounding, &b) == 0) opts.Use_Slabs = b; if(POVMSUtil_GetInt(msg, kPOVAttrib_BoundingThreshold, &i) == 0) { if(opts.BBox_Threshold < 1) Warning(0, "Too small bounding threshold adjusted to its minimum of one."); opts.BBox_Threshold = max(1, i); } if(POVMSUtil_GetBool(msg, kPOVAttrib_LightBuffer, &b) == 0) { if(b == true) opts.Options |= USE_LIGHT_BUFFER; else opts.Options &= ~USE_LIGHT_BUFFER; } if(POVMSUtil_GetBool(msg, kPOVAttrib_VistaBuffer, &b) == 0) { if(b == true) opts.Options |= USE_VISTA_BUFFER; else opts.Options &= ~USE_VISTA_BUFFER; } if(POVMSUtil_GetBool(msg, kPOVAttrib_Radiosity, &b) == 0) { Warning(0, "Radiosity commandline/INI switch is not needed in POV-Ray 3.5.\n" "Add a radiosity{}-block to your scene to turn on radiosity."); } if(POVMSUtil_GetBool(msg, kPOVAttrib_RemoveBounds, &b) == 0) { if(b == true) opts.Options |= REMOVE_BOUNDS; else opts.Options &= ~REMOVE_BOUNDS; } if(POVMSUtil_GetBool(msg, kPOVAttrib_SplitUnions, &b) == 0) { if(b == true) opts.Options |= SPLIT_UNION; else opts.Options &= ~SPLIT_UNION; } if(POVMSUtil_GetBool(msg, kPOVAttrib_Antialias, &b) == 0) { if(b == true) opts.Options |= ANTIALIAS; else opts.Options &= ~ANTIALIAS; } if(POVMSUtil_GetInt(msg, kPOVAttrib_SamplingMethod, &i) == 0) opts.Tracing_Method = i; if(POVMSUtil_GetFloat(msg, kPOVAttrib_AntialiasThreshold, &f) == 0) opts.Antialias_Threshold = f; if(POVMSUtil_GetInt(msg, kPOVAttrib_AntialiasDepth, &i) == 0) { opts.AntialiasDepth = i; if(opts.AntialiasDepth < 1) opts.AntialiasDepth = 1; if(opts.AntialiasDepth > 9) opts.AntialiasDepth = 9; } if(POVMSUtil_GetBool(msg, kPOVAttrib_Jitter, &b) == 0) { if(b == true) opts.Options |= JITTER; else opts.Options &= ~JITTER; } if(POVMSUtil_GetFloat(msg, kPOVAttrib_JitterAmount, &f) == 0) { opts.JitterScale = f; if(opts.JitterScale <= 0.0) opts.Options &= ~JITTER; } if(POVMSObject_Exist(msg, kPOVAttrib_IncludeHeader) == 0) { l = FILE_NAME_LENGTH; opts.Header_File_Name[0] = '\0'; (void)POVMSUtil_GetString(msg, kPOVAttrib_IncludeHeader, opts.Header_File_Name, &l); } (void)POVMSObject_Get(msg, &opts.Declared_Variables, kPOVAttrib_Declare); if(result != NULL) (void)BuildRenderOptions(result); return 0; }
// For this version, the work flow is that we first lookup the left table, and // use the result to lookup right table. If left table is done that means right // table is also done. So we only keep the left_child_done_ as the sign. bool NestedLoopJoinExecutor::DExecute() { LOG_TRACE("********** Nested Loop %s Join executor :: 2 children ", GetJoinTypeString()); // Grab info from plan node and check it const planner::NestedLoopJoinPlan &node = GetPlanNode<planner::NestedLoopJoinPlan>(); // Pick out the left and right columns const std::vector<oid_t> &join_column_ids_left = node.GetJoinColumnsLeft(); const std::vector<oid_t> &join_column_ids_right = node.GetJoinColumnsRight(); // We should first deal with the current result. Otherwise we will cache a lot // data which is not good to utilize memory. After that we call child execute. // Since is the high level idea, each time we get tile from left, we should // finish this tile, and then call child[0] execute for next tile. for (;;) { //===------------------------------------------------------------------===// // Pick left and right tiles //===------------------------------------------------------------------===// // If we have already retrieved all left child's results in buffer if (left_child_done_ == true) { LOG_TRACE("Left is done which means all join comparison completes"); return false; } // If left tile result is not done, continue the left tuples if (!left_tile_done_) { // Tuple result ContainerTuple<executor::LogicalTile> left_tuple(left_tile_.get(), left_tile_row_itr_); // Grab the values if (!join_column_ids_left.empty() && !join_column_ids_right.empty()) { std::vector<type::Value> join_values; for (auto column_id : join_column_ids_left) { type::Value predicate_value = left_tuple.GetValue(column_id); join_values.push_back(predicate_value); } // Pass the columns and values to right executor LOG_TRACE("Update the new value for index predicate"); children_[1]->UpdatePredicate(join_column_ids_right, join_values); } // Execute the right child to get the right tile if (children_[1]->Execute() == true) { LOG_TRACE("Advance the Right child."); std::unique_ptr<LogicalTile> right_tile(children_[1]->GetOutput()); PL_ASSERT(right_tile != nullptr); // Construct output result auto output_tile = BuildOutputLogicalTile(left_tile_.get(), right_tile.get()); // Build position list LogicalTile::PositionListsBuilder pos_lists_builder(left_tile_.get(), right_tile.get()); // Go over every pair of tuples in left and right logical tiles for (auto right_tile_row_itr : *right_tile) { // Insert a tuple into the output logical tile // First, copy the elements in left logical tile's tuple LOG_TRACE("Insert a tuple into the output logical tile"); ContainerTuple<executor::LogicalTile> right_tuple(right_tile.get(), right_tile_row_itr); if (predicate_ != nullptr) { auto eval = predicate_->Evaluate(&left_tuple, &right_tuple, executor_context_); // Join predicate is false. Skip pair and continue. if (eval.IsFalse()) { LOG_TRACE("Not math join predicate"); continue; } LOG_TRACE("Find a tuple with join predicate"); } pos_lists_builder.AddRow(left_tile_row_itr_, right_tile_row_itr); } // Outer loop of NLJ // Now current left tile is done LOG_TRACE("pos_lists_builder's size : %ld", pos_lists_builder.Size()); if (pos_lists_builder.Size() > 0) { LOG_TRACE("Set output result"); output_tile->SetPositionListsAndVisibility( pos_lists_builder.Release()); SetOutput(output_tile.release()); LOG_TRACE("result is : %s", GetOutputInfo()->GetInfo().c_str()); return true; } continue; } // Right table is finished for the current left tuple. move to the next else { if (!left_child_done_) { LOG_TRACE("right child is done, but left is not, so reset right"); children_[1]->ResetState(); // When all right table is done, examine whether left tile is done // If left tile is done, next loop will directly execute child[0] if (left_tile_row_itr_ == left_tile_->GetTupleCount() - 1) { LOG_TRACE("left tile is done"); // Set up flag and go the execute child 0 to get the next tile left_tile_done_ = true; } else { // Move the row to the next one in left tile LOG_TRACE("Advance left row"); left_tile_row_itr_++; // Continue the new left row continue; } } else { LOG_TRACE("Both left and right child are done"); right_child_done_ = true; return false; } } } // End handle left tile // Otherwise, we must attempt to execute the left child to get a new left // tile // Left child is finished, no more tiles if (children_[0]->Execute() == false) { LOG_TRACE("Left child is exhausted."); return false; } // Cache the new tile else { // Get the left child's result LOG_TRACE("Retrieve a new tile from left child"); left_tile_.reset(children_[0]->GetOutput()); // Set the flag with init status left_tile_done_ = false; left_tile_row_itr_ = 0; } LOG_TRACE("Get a new left tile. Continue the loop."); } // end the very beginning for loop }
TEST(logcat, logrotate_continue) { static const char tmp_out_dir_form[] = "/data/local/tmp/logcat.logrotate.XXXXXX"; char tmp_out_dir[sizeof(tmp_out_dir_form)]; ASSERT_TRUE(NULL != mkdtemp(strcpy(tmp_out_dir, tmp_out_dir_form))); static const char log_filename[] = "log.txt"; static const char logcat_cmd[] = "logcat -b all -d -f %s/%s -n 256 -r 1024"; static const char cleanup_cmd[] = "rm -rf %s"; char command[sizeof(tmp_out_dir) + sizeof(logcat_cmd) + sizeof(log_filename)]; snprintf(command, sizeof(command), logcat_cmd, tmp_out_dir, log_filename); int ret; EXPECT_FALSE(IsFalse(ret = system(command), command)); if (ret) { snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir); EXPECT_FALSE(IsFalse(system(command), command)); return; } FILE *fp; snprintf(command, sizeof(command), "%s/%s", tmp_out_dir, log_filename); EXPECT_TRUE(NULL != ((fp = fopen(command, "r")))); if (!fp) { snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir); EXPECT_FALSE(IsFalse(system(command), command)); return; } char *line = NULL; char *last_line = NULL; // this line is allowed to stutter, one-line overlap char *second_last_line = NULL; size_t len = 0; while (getline(&line, &len, fp) != -1) { free(second_last_line); second_last_line = last_line; last_line = line; line = NULL; } fclose(fp); free(line); if (second_last_line == NULL) { fprintf(stderr, "No second to last line, using last, test may fail\n"); second_last_line = last_line; last_line = NULL; } free(last_line); EXPECT_TRUE(NULL != second_last_line); if (!second_last_line) { snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir); EXPECT_FALSE(IsFalse(system(command), command)); return; } // re-run the command, it should only add a few lines more content if it // continues where it left off. snprintf(command, sizeof(command), logcat_cmd, tmp_out_dir, log_filename); EXPECT_FALSE(IsFalse(ret = system(command), command)); if (ret) { snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir); EXPECT_FALSE(IsFalse(system(command), command)); return; } std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(tmp_out_dir), closedir); EXPECT_NE(nullptr, dir); if (!dir) { snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir); EXPECT_FALSE(IsFalse(system(command), command)); return; } struct dirent *entry; unsigned count = 0; while ((entry = readdir(dir.get()))) { if (strncmp(entry->d_name, log_filename, sizeof(log_filename) - 1)) { continue; } snprintf(command, sizeof(command), "%s/%s", tmp_out_dir, entry->d_name); EXPECT_TRUE(NULL != ((fp = fopen(command, "r")))); if (!fp) { fprintf(stderr, "%s ?\n", command); continue; } line = NULL; size_t number = 0; while (getline(&line, &len, fp) != -1) { ++number; if (!strcmp(line, second_last_line)) { EXPECT_TRUE(++count <= 1); fprintf(stderr, "%s(%zu):\n", entry->d_name, number); } } fclose(fp); free(line); unlink(command); } if (count > 1) { char *brk = strpbrk(second_last_line, "\r\n"); if (!brk) { brk = second_last_line + strlen(second_last_line); } fprintf(stderr, "\"%.*s\" occured %u times\n", (int)(brk - second_last_line), second_last_line, count); } free(second_last_line); snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir); EXPECT_FALSE(IsFalse(system(command), command)); }
TEST (GWDMetacityDecorationUtilTest, TestBadThemeStringDecorationRevertsToCairo) { EXPECT_THAT (gwd_metacity_window_decoration_update_meta_theme (badTheme.c_str (), get_current_returns_null, set_current_seam), IsFalse ()); }
TEST (GWDMetacityDecorationUtilTest, TestNULLDecorationRevertsToCairo) { EXPECT_THAT (gwd_metacity_window_decoration_update_meta_theme (NULL, get_current_returns_nonnull, set_current_seam), IsFalse ()); }
TEST(logcat, logrotate_clear) { static const char tmp_out_dir_form[] = "/data/local/tmp/logcat.logrotate.XXXXXX"; char tmp_out_dir[sizeof(tmp_out_dir_form)]; ASSERT_TRUE(NULL != mkdtemp(strcpy(tmp_out_dir, tmp_out_dir_form))); static const char log_filename[] = "log.txt"; static const unsigned num_val = 32; static const char logcat_cmd[] = "logcat -b all -d -f %s/%s -n %d -r 1"; static const char clear_cmd[] = " -c"; static const char cleanup_cmd[] = "rm -rf %s"; char command[sizeof(tmp_out_dir) + sizeof(logcat_cmd) + sizeof(log_filename) + sizeof(clear_cmd) + 32]; // Run command with all data { snprintf(command, sizeof(command) - sizeof(clear_cmd), logcat_cmd, tmp_out_dir, log_filename, num_val); int ret; EXPECT_FALSE(IsFalse(ret = system(command), command)); if (ret) { snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir); EXPECT_FALSE(IsFalse(system(command), command)); return; } std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(tmp_out_dir), closedir); EXPECT_NE(nullptr, dir); if (!dir) { snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir); EXPECT_FALSE(IsFalse(system(command), command)); return; } struct dirent *entry; unsigned count = 0; while ((entry = readdir(dir.get()))) { if (strncmp(entry->d_name, log_filename, sizeof(log_filename) - 1)) { continue; } ++count; } EXPECT_EQ(count, num_val + 1); } { // Now with -c option tacked onto the end strcat(command, clear_cmd); int ret; EXPECT_FALSE(IsFalse(ret = system(command), command)); if (ret) { snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir); EXPECT_FALSE(system(command)); EXPECT_FALSE(IsFalse(system(command), command)); return; } std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(tmp_out_dir), closedir); EXPECT_NE(nullptr, dir); if (!dir) { snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir); EXPECT_FALSE(IsFalse(system(command), command)); return; } struct dirent *entry; unsigned count = 0; while ((entry = readdir(dir.get()))) { if (strncmp(entry->d_name, log_filename, sizeof(log_filename) - 1)) { continue; } fprintf(stderr, "Found %s/%s!!!\n", tmp_out_dir, entry->d_name); ++count; } EXPECT_EQ(count, 0U); } snprintf(command, sizeof(command), cleanup_cmd, tmp_out_dir); EXPECT_FALSE(IsFalse(system(command), command)); }
/** * @brief Creates logical tile from tile group and applies scan predicate. * @return true on success, false otherwise. */ bool SeqScanExecutor::DExecute() { // Scanning over a logical tile. if (children_.size() == 1 && // There will be a child node on the create index scenario, // but we don't want to use this execution flow !(GetRawNode()->GetChildren().size() > 0 && GetRawNode()->GetChildren()[0].get()->GetPlanNodeType() == PlanNodeType::CREATE && ((planner::CreatePlan *)GetRawNode()->GetChildren()[0].get()) ->GetCreateType() == CreateType::INDEX)) { // FIXME Check all requirements for children_.size() == 0 case. LOG_TRACE("Seq Scan executor :: 1 child "); PELOTON_ASSERT(target_table_ == nullptr); PELOTON_ASSERT(column_ids_.size() == 0); while (children_[0]->Execute()) { std::unique_ptr<LogicalTile> tile(children_[0]->GetOutput()); if (predicate_ != nullptr) { // Invalidate tuples that don't satisfy the predicate. for (oid_t tuple_id : *tile) { ContainerTuple<LogicalTile> tuple(tile.get(), tuple_id); auto eval = predicate_->Evaluate(&tuple, nullptr, executor_context_); if (eval.IsFalse()) { // if (predicate_->Evaluate(&tuple, nullptr, executor_context_) // .IsFalse()) { tile->RemoveVisibility(tuple_id); } } } if (0 == tile->GetTupleCount()) { // Avoid returning empty tiles continue; } /* Hopefully we needn't do projections here */ SetOutput(tile.release()); return true; } return false; } // Scanning a table else if (children_.size() == 0 || // If we are creating an index, there will be a child (children_.size() == 1 && // This check is only needed to pass seq_scan_test // unless it is possible to add a executor child // without a corresponding plan. GetRawNode()->GetChildren().size() > 0 && // Check if the plan is what we actually expect. GetRawNode()->GetChildren()[0].get()->GetPlanNodeType() == PlanNodeType::CREATE && // If it is, confirm it is for indexes ((planner::CreatePlan *)GetRawNode()->GetChildren()[0].get()) ->GetCreateType() == CreateType::INDEX)) { LOG_TRACE("Seq Scan executor :: 0 child "); PELOTON_ASSERT(target_table_ != nullptr); PELOTON_ASSERT(column_ids_.size() > 0); if (children_.size() > 0 && !index_done_) { children_[0]->Execute(); // This stops continuous executions due to // a parent and avoids multiple creations // of the same index. index_done_ = true; } concurrency::TransactionManager &transaction_manager = concurrency::TransactionManagerFactory::GetInstance(); bool acquire_owner = GetPlanNode<planner::AbstractScan>().IsForUpdate(); auto current_txn = executor_context_->GetTransaction(); // Retrieve next tile group. while (current_tile_group_offset_ < table_tile_group_count_) { auto tile_group = target_table_->GetTileGroup(current_tile_group_offset_++); auto tile_group_header = tile_group->GetHeader(); oid_t active_tuple_count = tile_group->GetNextTupleSlot(); // Construct position list by looping through tile group // and applying the predicate. std::vector<oid_t> position_list; for (oid_t tuple_id = 0; tuple_id < active_tuple_count; tuple_id++) { ItemPointer location(tile_group->GetTileGroupId(), tuple_id); auto visibility = transaction_manager.IsVisible( current_txn, tile_group_header, tuple_id); // check transaction visibility if (visibility == VisibilityType::OK) { // if the tuple is visible, then perform predicate evaluation. if (predicate_ == nullptr) { position_list.push_back(tuple_id); auto res = transaction_manager.PerformRead(current_txn, location, acquire_owner); if (!res) { transaction_manager.SetTransactionResult(current_txn, ResultType::FAILURE); return res; } } else { ContainerTuple<storage::TileGroup> tuple(tile_group.get(), tuple_id); LOG_TRACE("Evaluate predicate for a tuple"); auto eval = predicate_->Evaluate(&tuple, nullptr, executor_context_); LOG_TRACE("Evaluation result: %s", eval.GetInfo().c_str()); if (eval.IsTrue()) { position_list.push_back(tuple_id); auto res = transaction_manager.PerformRead(current_txn, location, acquire_owner); if (!res) { transaction_manager.SetTransactionResult(current_txn, ResultType::FAILURE); return res; } else { LOG_TRACE("Sequential Scan Predicate Satisfied"); } } } } } // Don't return empty tiles if (position_list.size() == 0) { continue; } // Construct logical tile. std::unique_ptr<LogicalTile> logical_tile(LogicalTileFactory::GetTile()); logical_tile->AddColumns(tile_group, column_ids_); logical_tile->AddPositionList(std::move(position_list)); LOG_TRACE("Information %s", logical_tile->GetInfo().c_str()); SetOutput(logical_tile.release()); return true; } } return false; }
std::unique_ptr<Graph> graph; int numberOfNodes = 42; before_each([&](){ graph.reset(new Graph); randomBiconnectedGraph(*graph, numberOfNodes, 3*numberOfNodes); }); it("is well-formed", [&]() { GraphAttributes attr(*graph); pugi::xml_document doc; createDocument(attr, doc); pugi::xml_node svg = doc.child("svg"); AssertThat((bool) svg, IsTrue()); AssertThat(svg.attribute("viewBox").empty(), IsFalse()); AssertThat(static_cast<int>(svg.select_nodes("//rect").size()), Equals(graph->numberOfNodes())); AssertThat(static_cast<int>(svg.select_nodes("//path").size()), Equals(graph->numberOfEdges())); }); it("supports 3D", [&]() { GraphAttributes attr(*graph, GraphAttributes::nodeGraphics | GraphAttributes::nodeStyle | GraphAttributes::edgeGraphics | GraphAttributes::threeD | GraphAttributes::nodeLabel | GraphAttributes::nodeLabelPosition); List<node> nodes; graph->allNodes(nodes);