Beispiel #1
0
    def getCommand( self, outfile ):
        # NOTE: the trailing slashes are necessary for rsync to copy the
        # contents to the temp directory without an extra directory layer

        inputdir = {
            "test":   "inputs/sequenceB_1/",
            "tiny":   "inputs/sequenceB_1/",
            "small":  "inputs/sequenceB_1/",
            "medium": "inputs/sequenceB_2/",
            "large":  "inputs/sequenceB_4/",
            "huge":   "inputs/sequenceB_261/",
        }[ self.size ]
        Multitmp.check_call( [ "rm", "-f", outfile ] )
        Multitmp.check_call( [ "rsync", "-a", inputdir, outfile ] )

        cmd = [ self.exe, outfile, "4" ]
        cmd += {
            "test":   [   "1",    "5", "1" ],
            "tiny":   [   "1",  "100", "3" ],
            "small":  [   "1", "1000", "5" ],
            "medium": [   "2", "2000", "5" ],
            "large":  [   "4", "4000", "5" ],
            "huge":   [ "261", "4000", "5" ],
        }[ self.size ]
        cmd += [ "0", "1" ]
        return cmd, dict()
Beispiel #2
0
    def diff( self, golden, actual ):
        if not self.options.error:
            return ParallelTest.diff( self, golden, actual )

        with Multitmp( len( actual ) ) as count:
            Multitmp.check_call(
                [ os.path.join( root, "bin", "hamming" ), golden, actual ],
                stdout = count, verbose = self.options.verbose
            )
            self.error = list()
            for fname in count:
                with open( fname ) as fh:
                    for line in fh:
                        self.error.append( 1.0 / ( 1 + float( line.strip() ) ) )
                        break
        return True
Beispiel #3
0
 def diff( self, golden, actual ):
     if not self.options.error:
         return ParallelTest.diff( self, golden, actual )
     with Multitmp( len( actual ) ) as result:
         Multitmp.check_call(
             [ "./freqdiff", golden, actual ],
             stdout = result, verbose = self.options.verbose
         )
         self.error = list()
         for fname in result:
             with open( fname ) as fh:
                 for line in fh:
                     self.error.append( 1 / ( 1 + float( line.strip() ) ) )
                     break
                 else:
                     self.error.append( 0 )
     return True
Beispiel #4
0
 def validateCorrectness( self, outfile ):
     correctness = ParallelTest.validateCorrectness( self, outfile )
     with Multitmp( len( outfile ) ) as tmp:
         Multitmp.check_call(
             [ "sed", "-e", "/^#im_vips2ppm/d", outfile ],
             stdout = tmp
         )
         Multitmp.check_call( [ "mv", tmp, outfile ] )
         if self.options.error:
             with Multitmp( len( outfile ) ) as result:
                 with open( "/dev/null", 'w' ) as null:
                     golden = self.getGolden()
                     diffimg = os.path.join( root, "bin", "diff-img")
                     Multitmp.check_call(
                         [ diffimg,
                           golden,
                           outfile
                         ],
                         stdout = result, stderr = null,
                         verbose = self.options.verbose,
                     )
                 errors = list()
                 for fname in result:
                     with open( fname ) as fh:
                         error = 0
                         for line in fh:
                             if line.startswith( "total" ):
                                 error += float( line.split()[ 2 ] )
                         errors.append( 1 / ( error + 1 ) )
                 self.error = errors
                 return True
         else:
             return correctness
Beispiel #5
0
    def diff( self, golden, actual ):
        if not self.options.error:
            return ParallelTest.diff( self, golden, actual )

        with Multitmp( len( actual ) ) as result:
            with open( "/dev/null", 'w' ) as null:
                diffimg = os.path.join( root, "bin", "diff-img.sh")
                Multitmp.check_call(
                    [ diffimg, golden, actual ],
                    stdout = result, stderr = null,
                    verbose = self.options.verbose,
                )
            errors = list()
            for fname in result:
                with open( fname ) as fh:
                    error = 0
                    for line in fh:
                        if line.startswith( "total" ):
                            error += float( line.split()[ 2 ] )
                    errors.append( 1 / ( error + 1 ) )
            self.error = errors
            return True
Beispiel #6
0
    def getCommand(self, outfile):
        if self.size == "huge":
            inputdir = "inputs/native/Face_Data"
        else:
            inputdir = "inputs/%s/Face_Data" % self.size
        Multitmp.check_call(["rm", "-f", outfile])
        Multitmp.check_call(["mkdir", outfile])
        Multitmp.check_call(["rsync", "-a", inputdir, outfile])

        cmd = [os.path.join(os.getcwd(), self.exe), "-timing", "-threads", "1"]

        return cmd, {"cwd": outfile}
Beispiel #7
0
 def validateCorrectness( self, outfile ):
     correctness = ParallelTest.validateCorrectness( self, outfile )
     if self.options.error:
         with Multitmp( len( outfile ) ) as outdir:
             Multitmp.check_call( [ "rm", "-rf", outdir ], verbose = self.options.verbose )
             Multitmp.check_call( [ "mkdir", outdir ], verbose = self.options.verbose )
             Multitmp.check_call(
                 [ "avconv",
                   "-i", outfile,
                   "-r", "25",
                   "-loglevel", "panic",
                   "%03d.png"
                 ],
                 verbose = self.options.verbose,
                 cwd = outdir
             )
             if not ParallelTest.validateCorrectness( self, outdir ):
                 return False
             with Multitmp( len( outfile ) ) as result:
                 with open( "/dev/null", 'w' ) as null:
                     golden = self.getGolden()
                     diffimg = os.path.join( root, "bin", "diff-img.sh")
                     Multitmp.check_call(
                         [ diffimg,
                           golden,
                           outdir
                         ],
                         stdout = result, stderr = null,
                         verbose = self.options.verbose,
                     )
                 errors = list()
                 for fname in result:
                     with open( fname ) as fh:
                         error = 0
                         for line in fh:
                             if line.startswith( "total" ):
                                 error += float( line.split()[ 2 ] )
                         errors.append( 1 / ( error + 1 ) )
                 self.error = errors
                 return True
     else:
         return correctness
Beispiel #8
0
 def validateCorrectness( self, outfile ):
     if self.options.error:
         with Multitmp( len( outfile ) ) as scratch:
             Multitmp.check_call(
                 [ "mv", outfile, scratch ], verbose = self.options.verbose
             )
             Multitmp.check_call(
                 [ "mkdir", outfile ], verbose = self.options.verbose
             )
             Multitmp.check_call(
                 [ "avconv",
                   "-i", scratch,
                   "-r", "25",
                   "-loglevel", "panic",
                   "%03d.png"
                 ],
                 verbose = self.options.verbose,
                 cwd = outfile
             )
             return ParallelTest.validateCorrectness( self, outfile )
     else:
         return ParallelTest.validateCorrectness( self, outfile )
Beispiel #9
0
 def validateCorrectness(self, outfile):
     Multitmp.check_call(["rm", "-rf", "Face_Data", "Storytelling/output/log.txt"], cwd=outfile)
     return ParallelTest.validateCorrectness(self, outfile)