This is an automated email from the ASF dual-hosted git repository.

cmcfarlen pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/10.1.x by this push:
     new 589a498cdf AuTest for Cripts (#12057)
589a498cdf is described below

commit 589a498cdfc4e00a5c9e1bc44eda6b92d53e71ca
Author: Nathan Wang <[email protected]>
AuthorDate: Wed Mar 12 10:50:06 2025 -0700

    AuTest for Cripts (#12057)
    
    * basic cripts AU test
    
    * add apache license to cript file
    
    * change comment format, cripts reads # as preprocessor directive
    
    * try using /tmp/ats as ATS root
    
    * remove unused compiler flag: -undefined dynamic_lookup
    
    ---------
    
    Co-authored-by: Nathan Wang <[email protected]>
    (cherry picked from commit a81932496f25ebef05ccff4643692f5759694b0b)
---
 tests/gold_tests/cripts/cripts.test.py        | 73 +++++++++++++++++++++++++++
 tests/gold_tests/cripts/files/basic.cript     | 33 ++++++++++++
 tests/gold_tests/cripts/gold/basic_cript.gold | 16 ++++++
 tools/cripts/compiler.sh                      |  4 +-
 4 files changed, 124 insertions(+), 2 deletions(-)

diff --git a/tests/gold_tests/cripts/cripts.test.py 
b/tests/gold_tests/cripts/cripts.test.py
new file mode 100644
index 0000000000..0f5326901e
--- /dev/null
+++ b/tests/gold_tests/cripts/cripts.test.py
@@ -0,0 +1,73 @@
+'''
+Test basic cripts functionality
+'''
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+Test.testName = "cripts: basic functions"
+Test.Summary = '''
+Simple cripts test that sets a response header back to the client
+'''
+Test.ContinueOnFail = True
+
+
+class CriptsBasicTest:
+
+    def __init__(self):
+        self.setUpOriginServer()
+        self.setUpTS()
+
+    def setUpOriginServer(self):
+        self.server = Test.MakeOriginServer("server")
+
+        request_header = {"headers": "GET / HTTP/1.1\r\nHost: 
www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""}
+        response_header = {
+            "headers": "HTTP/1.1 200 OK\r\responseHeader: unchanged\r\n\r\n",
+            "timestamp": "1469733493.993",
+            "body": ""
+        }
+        self.server.addResponse("sessionfile.log", request_header, 
response_header)
+
+    def setUpTS(self):
+        self.ts = Test.MakeATSProcess("ts")
+
+        self.ts.Setup.CopyAs('files/basic.cript', self.ts.Variables.CONFIGDIR)
+        self.ts.Setup.CopyAs('../../../tools/cripts/compiler.sh', 
"{0}/bin".format(Test.RunDirectory))
+
+        self.ts.Disk.records_config.update(
+            {
+                'proxy.config.diags.debug.enabled': 1,
+                'proxy.config.plugin.dynamic_reload_mode': 1,
+                'proxy.config.plugin.compiler_path': 
"{0}/bin/compiler.sh".format(Test.RunDirectory),
+            })
+
+        self.ts.Disk.remap_config.AddLine(
+            'map http://www.example.com http://127.0.0.1:{0} 
@plugin=basic.cript'.format(self.server.Variables.Port))
+
+    def runHeaderTest(self):
+        tr = Test.AddTestRun()
+        tr.Processes.Default.Command = 'curl -v -H "Host: www.example.com" 
http://127.0.0.1:{0}'.format(self.ts.Variables.port)
+        tr.Processes.Default.ReturnCode = 0
+        tr.Processes.Default.StartBefore(self.server, 
ready=When.PortOpen(self.server.Variables.Port))
+        tr.Processes.Default.StartBefore(self.ts)
+        tr.Processes.Default.Streams.stderr = "gold/basic_cript.gold"
+        tr.StillRunningAfter = self.server
+
+    def run(self):
+        self.runHeaderTest()
+
+
+CriptsBasicTest().run()
diff --git a/tests/gold_tests/cripts/files/basic.cript 
b/tests/gold_tests/cripts/files/basic.cript
new file mode 100644
index 0000000000..b8c136668a
--- /dev/null
+++ b/tests/gold_tests/cripts/files/basic.cript
@@ -0,0 +1,33 @@
+/*
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+*/
+
+#include <cripts/Preamble.hpp>
+
+do_read_response()
+{
+  borrow resp = cripts::Server::Response::Get();
+  resp["responseHeader"] = "changed";
+}
+
+do_send_response()
+{
+  borrow resp = cripts::Client::Response::Get();
+  resp["criptsResponseHeader"] = "response";
+}
+
+#include <cripts/Epilogue.hpp>
diff --git a/tests/gold_tests/cripts/gold/basic_cript.gold 
b/tests/gold_tests/cripts/gold/basic_cript.gold
new file mode 100644
index 0000000000..f3a6ea87f2
--- /dev/null
+++ b/tests/gold_tests/cripts/gold/basic_cript.gold
@@ -0,0 +1,16 @@
+``
+> GET / HTTP/1.1
+> Host: www.example.com
+> User-Agent: curl/``
+> Accept: */*
+> 
+``
+< HTTP/1.1 200 OK
+< responseHeader: changed
+< Date: ``
+< Age: ``
+< Connection: keep-alive
+< Server: ATS/``
+< criptsResponseHeader: response
+< 
+``
diff --git a/tools/cripts/compiler.sh b/tools/cripts/compiler.sh
index c2e4b4f840..e6a035f70a 100755
--- a/tools/cripts/compiler.sh
+++ b/tools/cripts/compiler.sh
@@ -24,9 +24,9 @@
 ##############################################################################
 
 # Configurable parts
-: ${ATS_ROOT:="/opt/ats"}
+: ${ATS_ROOT:="/tmp/ats"}
 : ${CXX:="clang++"}
-: ${CXXFLAGS:="-std=c++20 -I/opt/homebrew/include -undefined dynamic_lookup"}
+: ${CXXFLAGS:="-x c++ -std=c++20 -I/opt/homebrew/include"}
 
 # Probably don't need to change these ?
 STDFLAGS="-shared -fPIC -Wall -Werror -I${ATS_ROOT}/include -L${ATS_ROOT}/lib 
-lcripts"

Reply via email to