From 7c492694a6443a92fd349fda0c4c7b587040f161 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sat, 2 Jan 2016 15:23:15 +1100 Subject: [PATCH] cmd/webp-manual-test: blacklist some versions of the dwebp binary. In particular, the 0.4.0 version of /usr/bin/dwebp that comes with Ubuntu 14.04 LTS "Trusty", is known to be bad. As per https://chromium.googlesource.com/webm/libwebp/+/master/NEWS (grep for 239), versions 0.4.1 and 0.4.2 are also bad. The alpha_color_cache.webp test file that triggers the discrepancy between the (correct) Go implementation and the (buggy) libwebp C implementation was added on 2015-01-23 in https://chromium.googlesource.com/webm/libwebp-test-data/+/f64fb2da0175fb620540f076a4ba3d310b015a29 in response to https://bugs.chromium.org/p/webp/issues/detail?id=239 Change-Id: Ifee19be0af634b9bf36ff0e16957648e05be840a Reviewed-on: https://go-review.googlesource.com/18186 Reviewed-by: David Crawshaw --- cmd/webp-manual-test/main.go | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/cmd/webp-manual-test/main.go b/cmd/webp-manual-test/main.go index c041e21..296c763 100644 --- a/cmd/webp-manual-test/main.go +++ b/cmd/webp-manual-test/main.go @@ -38,13 +38,9 @@ var ( func main() { flag.Parse() - if *dwebp == "" { + if err := checkDwebp(); err != nil { flag.Usage() - log.Fatal("dwebp flag was not specified") - } - if _, err := os.Stat(*dwebp); err != nil { - flag.Usage() - log.Fatalf("could not find dwebp program at %q", *dwebp) + log.Fatal(err) } if *testdata == "" { flag.Usage() @@ -81,6 +77,25 @@ func main() { } } +func checkDwebp() error { + if *dwebp == "" { + return fmt.Errorf("dwebp flag was not specified") + } + if _, err := os.Stat(*dwebp); err != nil { + return fmt.Errorf("could not find dwebp program at %q", *dwebp) + } + b, err := exec.Command(*dwebp, "-version").Output() + if err != nil { + return fmt.Errorf("could not determine the dwebp program version for %q: %v", *dwebp, err) + } + switch s := string(bytes.TrimSpace(b)); s { + case "0.4.0", "0.4.1", "0.4.2": + return fmt.Errorf("the dwebp program version %q for %q has a known bug "+ + "(https://bugs.chromium.org/p/webp/issues/detail?id=239). Please use a newer version.", s, *dwebp) + } + return nil +} + // test tests a single WEBP image. func test(name string) error { filename := filepath.Join(*testdata, name)