From: Simon McVittie <smcv@debian.org>
Date: Thu, 18 Nov 2021 10:14:41 +0000
Subject: testgfx: Add an option to run one complete cycle and then stop

This allows this program to be used as a non-interactive smoke test.

Signed-off-by: Simon McVittie <smcv@debian.org>
---
 test/TestGfx.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/test/TestGfx.c b/test/TestGfx.c
index d7ecbef..3bdd449 100755
--- a/test/TestGfx.c
+++ b/test/TestGfx.c
@@ -1708,6 +1708,8 @@ int TestBigEllipse(SDL_Renderer *renderer)
 int main(int argc, char *argv[])
 {
     int i, done, drawn, test = 0;
+    int once = 0;
+    int firstTest = -1;
     SDL_Event event;
     Uint32 then, now, frames;
     int numTests;
@@ -1732,6 +1734,10 @@ int main(int argc, char *argv[])
                  consumed = 2;
                }
             }
+           else if (SDL_strcasecmp(argv[i], "--once") == 0) {
+               once = 1;
+               consumed = 1;
+           }
         }
                  
            
@@ -1809,6 +1815,14 @@ int main(int argc, char *argv[])
 				test = test % numTests;
 			}
 
+			if (firstTest < 0) {
+				firstTest = test;
+			}
+			else if (test == firstTest) {
+				done = 1;
+				break;
+			}
+
 			/* Create random points */
 			InitRandomPoints(test);
 
@@ -1940,6 +1954,12 @@ int main(int argc, char *argv[])
 			drawn = 1;
 		}
 
+		if (once) {
+			drawn = 0;
+			test++;
+			continue;
+		}
+
 		/* Adjust framerate */
 		SDL_Delay(25);
     }
