diff options
author | Csaba Hruska <csaba.hruska@gmail.com> | 2016-02-15 12:53:32 +0100 |
---|---|---|
committer | Csaba Hruska <csaba.hruska@gmail.com> | 2016-02-15 12:53:32 +0100 |
commit | 9034bb009ea53bc5d392d87c19fec36c143d3867 (patch) | |
tree | 33b03f1f3066eb4cb22115d7fc304d7afbb9182c /backendtest | |
parent | 75dc96c2e0946f895efe3119fd43b8500ca18115 (diff) |
improve backend test and add results
Diffstat (limited to 'backendtest')
-rw-r--r-- | backendtest/BACKEND-TEST-FRAMEWORK | 2 | ||||
-rw-r--r-- | backendtest/EditorExamplesTest.hs | 19 | ||||
-rw-r--r-- | backendtest/TestServer.hs | 24 | ||||
-rw-r--r-- | backendtest/logo256x256.png | bin | 35777 -> 0 bytes |
4 files changed, 22 insertions, 23 deletions
diff --git a/backendtest/BACKEND-TEST-FRAMEWORK b/backendtest/BACKEND-TEST-FRAMEWORK index b1414003..96e2db03 100644 --- a/backendtest/BACKEND-TEST-FRAMEWORK +++ b/backendtest/BACKEND-TEST-FRAMEWORK | |||
@@ -35,6 +35,6 @@ roadmap: | |||
35 | done - interpret the incoming scene data in test client | 35 | done - interpret the incoming scene data in test client |
36 | next: | 36 | next: |
37 | done - receive the render job results | 37 | done - receive the render job results |
38 | construct the test scene in server side | 38 | done - construct the test scene in server side |
39 | later - create EDSL for backend tests (configuring data + schema + pipeline) | 39 | later - create EDSL for backend tests (configuring data + schema + pipeline) |
40 | done - compare result with the validated image \ No newline at end of file | 40 | done - compare result with the validated image \ No newline at end of file |
diff --git a/backendtest/EditorExamplesTest.hs b/backendtest/EditorExamplesTest.hs index 742b3e59..4e405745 100644 --- a/backendtest/EditorExamplesTest.hs +++ b/backendtest/EditorExamplesTest.hs | |||
@@ -86,15 +86,16 @@ getRenderJob = do | |||
86 | , pipeline = ppl | 86 | , pipeline = ppl |
87 | } | 87 | } |
88 | 88 | ||
89 | img <- unpack . B64.encode <$> BS.readFile "./backendtest/logo256x256.png" | 89 | img <- unpack . B64.encode <$> BS.readFile "./backend-test-data/editor/logo256x256.png" |
90 | 90 | ||
91 | return $ RenderJob | 91 | let job = RenderJob |
92 | { meshes = V.fromList [cubeMesh] | 92 | { meshes = V.fromList [cubeMesh] |
93 | , TD.textures = V.fromList [img] | 93 | , TD.textures = V.fromList [img] |
94 | , schema = inputSchema | 94 | , schema = inputSchema |
95 | , scenes = V.fromList [scene 64] | 95 | , scenes = V.fromList [scene 64] |
96 | , pipelines = V.fromList ppls | 96 | , pipelines = V.fromList ppls |
97 | } | 97 | } |
98 | return ("editor",job) | ||
98 | 99 | ||
99 | g_vertex_buffer_data = | 100 | g_vertex_buffer_data = |
100 | [ V4 1.0 1.0 (-1.0) 1.0 | 101 | [ V4 1.0 1.0 (-1.0) 1.0 |
diff --git a/backendtest/TestServer.hs b/backendtest/TestServer.hs index 58e49254..a84fc72b 100644 --- a/backendtest/TestServer.hs +++ b/backendtest/TestServer.hs | |||
@@ -38,32 +38,30 @@ application pending = do | |||
38 | flip finally disconnect $ do | 38 | flip finally disconnect $ do |
39 | -- receive client info | 39 | -- receive client info |
40 | decodeStrict <$> WS.receiveData conn >>= \case | 40 | decodeStrict <$> WS.receiveData conn >>= \case |
41 | Nothing -> putStrLn "invalid client info" | 41 | Nothing -> fail "invalid client info" |
42 | Just ci@ClientInfo{..} -> print ci | 42 | Just ci@ClientInfo{..} -> print ci |
43 | -- send pipeline | 43 | -- send pipeline |
44 | --renderJob@RenderJob{..} <- testRenderJob | 44 | (testName,renderJob@RenderJob{..}) <- EditorExamplesTest.getRenderJob -- TODO |
45 | renderJob@RenderJob{..} <- EditorExamplesTest.getRenderJob -- TODO | ||
46 | WS.sendTextData conn . encode $ renderJob | 45 | WS.sendTextData conn . encode $ renderJob |
47 | -- TODO: get render result: pipeline x scene x frame | 46 | -- get render result: pipeline x scene x frame |
48 | forM_ [one..length pipelines] $ \pIdx -> do | 47 | forM_ pipelines $ \PipelineInfo{..} -> do |
49 | putStrLn $ "pipeline: " ++ pipelineName (pipelines V.! (pIdx - 1)) | ||
50 | forM_ (zip [one..] $ V.toList scenes) $ \(sIdx,Scene{..}) -> | 48 | forM_ (zip [one..] $ V.toList scenes) $ \(sIdx,Scene{..}) -> |
51 | forM_ [one..length frames] $ \fIdx -> do | 49 | forM_ [one..length frames] $ \fIdx -> do |
50 | let name = "backend-test-data/" ++ testName ++ "/result/" ++ takeBaseName pipelineName ++ "_scn" ++ printf "%02d" sIdx ++ "_" ++ printf "%02d" fIdx ++ ".png" | ||
52 | decodeStrict <$> WS.receiveData conn >>= \case | 51 | decodeStrict <$> WS.receiveData conn >>= \case |
53 | Nothing -> putStrLn "invalid RenderJobResult" | 52 | Nothing -> fail $ name ++ " - invalid RenderJobResult" |
54 | Just (RenderJobError e) -> fail $ "render error:\n" ++ e -- TODO: test failed | 53 | Just (RenderJobError e) -> fail $ name ++ " - render error:\n" ++ e -- TODO: test failed |
55 | Just (RenderJobResult FrameResult{..}) -> do | 54 | Just (RenderJobResult FrameResult{..}) -> do |
56 | let name = "backend-test-images/ppl" ++ printf "%02d" pIdx ++ "_scn" ++ printf "%02d" sIdx ++ "_" ++ printf "%02d" fIdx ++ ".png" | ||
57 | createDirectoryIfMissing True (takeDirectory name) | 55 | createDirectoryIfMissing True (takeDirectory name) |
58 | compareOrSaveImage name =<< toImage frImageWidth frImageHeight . either error id . B64.decode =<< WS.receiveData conn | 56 | compareOrSaveImage name =<< toImage frImageWidth frImageHeight . either error id . B64.decode =<< WS.receiveData conn |
59 | putStrLn $ name ++ "\t" ++ unwords (map showTime . V.toList $ frRenderTimes) | 57 | --putStrLn $ name ++ "\t" ++ unwords (map showTime . V.toList $ frRenderTimes) |
60 | putStrLn "render job done" | 58 | putStrLn "render job done" |
61 | forever $ threadDelay 1000000 | 59 | forever $ threadDelay 1000000 |
62 | 60 | ||
63 | compareOrSaveImage name img@(Image w h pixels) = do | 61 | compareOrSaveImage name img@(Image w h pixels) = do |
64 | doesFileExist name >>= \case | 62 | doesFileExist name >>= \case |
65 | False -> do | 63 | False -> do |
66 | putStrLn $ "save image: " ++ name | 64 | putStrLn $ "new image: " ++ name |
67 | savePngImage name (ImageRGBA8 img) | 65 | savePngImage name (ImageRGBA8 img) |
68 | True -> do | 66 | True -> do |
69 | Right (ImageRGBA8 (Image origW origH origPixels)) <- readImage name | 67 | Right (ImageRGBA8 (Image origW origH origPixels)) <- readImage name |
@@ -72,8 +70,8 @@ compareOrSaveImage name img@(Image w h pixels) = do | |||
72 | threshold = 0 | 70 | threshold = 0 |
73 | case (w /= origW || h /= origH || diff > threshold) of | 71 | case (w /= origW || h /= origH || diff > threshold) of |
74 | True -> do | 72 | True -> do |
75 | putStrLn $ "images differ!!! " ++ show diff | 73 | fail $ name ++ " - differ!!! " ++ show diff |
76 | False -> putStrLn $ "image match " ++ show diff | 74 | False -> putStrLn $ name ++ " OK" |
77 | 75 | ||
78 | toImage :: Int -> Int -> BS.ByteString -> IO (Image PixelRGBA8) | 76 | toImage :: Int -> Int -> BS.ByteString -> IO (Image PixelRGBA8) |
79 | toImage w h buf = do | 77 | toImage w h buf = do |
diff --git a/backendtest/logo256x256.png b/backendtest/logo256x256.png deleted file mode 100644 index 2c0c985c..00000000 --- a/backendtest/logo256x256.png +++ /dev/null | |||
Binary files differ | |||