Skip to content

Commit

Permalink
adding utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
fogleman committed Mar 28, 2015
1 parent c151e71 commit 44c98ea
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions util/roms.go
@@ -0,0 +1,52 @@
package main

import (
"fmt"
"io/ioutil"
"log"
"os"
"path"
"strings"

"github.com/fogleman/nes/nes"
)

func testRom(path string) (err error) {
defer func() {
if r := recover(); r != nil {
err = r.(error)
}
}()
console, err := nes.NewConsole(path)
if err != nil {
return err
}
console.StepSeconds(3)
return nil
}

func main() {
args := os.Args[1:]
if len(args) != 1 {
log.Fatalln("Usage: go run util/roms.go roms_directory")
}
dir := args[0]
infos, err := ioutil.ReadDir(dir)
if err != nil {
panic(err)
}
for _, info := range infos {
name := info.Name()
if !strings.HasSuffix(name, ".nes") {
continue
}
name = path.Join(dir, name)
err := testRom(name)
if err == nil {
fmt.Println("OK ", name)
} else {
fmt.Println("FAIL", name)
fmt.Println(err)
}
}
}

0 comments on commit 44c98ea

Please sign in to comment.