<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/testsuite/+/13572">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, but someone else must approve
  Corey Farrell: Looks good to me, approved
  Friendly Automation: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">testsuite: Use CSafeLoader instead of SafeLoader when possible<br><br>This speeds up YAML parsing about 8x on my machine. The two YAML file changes<br>are to fix a parsing error that only seems to occur with CSafeLoader.<br><br>Change-Id: I4eb4b17d29e32e1ca7e1d260d7d0e59e4646a18e<br>---<br>M lib/python/asterisk/test_config.py<br>M lib/python/asterisk/test_runner.py<br>M runtests.py<br>M tests/hep/rtcp-receiver/test-config.yaml<br>M tests/hep/rtcp-sender/test-config.yaml<br>M usage.py<br>6 files changed, 39 insertions(+), 19 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/lib/python/asterisk/test_config.py b/lib/python/asterisk/test_config.py</span><br><span>index 4860cb3..b395e63 100644</span><br><span>--- a/lib/python/asterisk/test_config.py</span><br><span>+++ b/lib/python/asterisk/test_config.py</span><br><span>@@ -16,6 +16,11 @@</span><br><span> import socket</span><br><span> import traceback</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+try:</span><br><span style="color: hsl(120, 100%, 40%);">+    from yaml import CSafeLoader as MyLoader</span><br><span style="color: hsl(120, 100%, 40%);">+except ImportError:</span><br><span style="color: hsl(120, 100%, 40%);">+    from yaml import SafeLoader as MyLoader</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> sys.path.append("lib/python")</span><br><span> </span><br><span> from . import test_suite_utils</span><br><span>@@ -374,7 +379,7 @@</span><br><span> </span><br><span>         test_config = "%s/test-config.yaml" % self.test_name</span><br><span>         with open(test_config, "r") as config_file:</span><br><span style="color: hsl(0, 100%, 40%);">-            self.config = yaml.load(config_file, Loader=yaml.SafeLoader)</span><br><span style="color: hsl(120, 100%, 40%);">+            self.config = yaml.load(config_file, Loader=MyLoader)</span><br><span> </span><br><span>         if not self.config:</span><br><span>             print("ERROR: Failed to load configuration for test '%s'" %</span><br><span>diff --git a/lib/python/asterisk/test_runner.py b/lib/python/asterisk/test_runner.py</span><br><span>index 443b712..588a6bb 100644</span><br><span>--- a/lib/python/asterisk/test_runner.py</span><br><span>+++ b/lib/python/asterisk/test_runner.py</span><br><span>@@ -17,6 +17,11 @@</span><br><span> import os</span><br><span> import yaml</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+try:</span><br><span style="color: hsl(120, 100%, 40%);">+    from yaml import CSafeLoader as MyLoader</span><br><span style="color: hsl(120, 100%, 40%);">+except ImportError:</span><br><span style="color: hsl(120, 100%, 40%);">+    from yaml import SafeLoader as MyLoader</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> from twisted.internet import reactor</span><br><span> </span><br><span> LOGGER = logging.getLogger('test_runner')</span><br><span>@@ -233,7 +238,7 @@</span><br><span>         return test_config</span><br><span> </span><br><span>     with open(test_config_path) as file_stream:</span><br><span style="color: hsl(0, 100%, 40%);">-        test_config = yaml.load(file_stream, Loader=yaml.SafeLoader)</span><br><span style="color: hsl(120, 100%, 40%);">+        test_config = yaml.load(file_stream, Loader=MyLoader)</span><br><span> </span><br><span>     return test_config</span><br><span> </span><br><span>diff --git a/runtests.py b/runtests.py</span><br><span>index fe04213..dac72b0 100755</span><br><span>--- a/runtests.py</span><br><span>+++ b/runtests.py</span><br><span>@@ -24,6 +24,11 @@</span><br><span> import re</span><br><span> </span><br><span> try:</span><br><span style="color: hsl(120, 100%, 40%);">+    from yaml import CSafeLoader as MyLoader</span><br><span style="color: hsl(120, 100%, 40%);">+except ImportError:</span><br><span style="color: hsl(120, 100%, 40%);">+    from yaml import SafeLoader as MyLoader</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+try:</span><br><span>     import lxml.etree as ET</span><br><span> except:</span><br><span>     # Ensure ET is defined</span><br><span>@@ -772,7 +777,7 @@</span><br><span>         print("Unexpected error: %s" % sys.exc_info()[0])</span><br><span>         return None</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-    config = yaml.load(f, Loader=yaml.SafeLoader)</span><br><span style="color: hsl(120, 100%, 40%);">+    config = yaml.load(f, Loader=MyLoader)</span><br><span>     f.close()</span><br><span> </span><br><span>     return config</span><br><span>diff --git a/tests/hep/rtcp-receiver/test-config.yaml b/tests/hep/rtcp-receiver/test-config.yaml</span><br><span>index c4008c3..961ae2a 100644</span><br><span>--- a/tests/hep/rtcp-receiver/test-config.yaml</span><br><span>+++ b/tests/hep/rtcp-receiver/test-config.yaml</span><br><span>@@ -73,7 +73,7 @@</span><br><span>                 value:</span><br><span>                     { ssrc: "\\d.*",</span><br><span>                       type: 201,</span><br><span style="color: hsl(0, 100%, 40%);">-                      report_blocks:[ { source_ssrc: "\\d.*",</span><br><span style="color: hsl(120, 100%, 40%);">+                      report_blocks: [ { source_ssrc: "\\d.*",</span><br><span>                                         highest_seq_no: "\\d.*",</span><br><span>                                         fraction_lost: 0,</span><br><span>                                         ia_jitter: "\\d.*",</span><br><span>@@ -137,7 +137,7 @@</span><br><span>                 value:</span><br><span>                     { ssrc: "\\d.*",</span><br><span>                       type: 201,</span><br><span style="color: hsl(0, 100%, 40%);">-                      report_blocks:[ { source_ssrc: "\\d.*",</span><br><span style="color: hsl(120, 100%, 40%);">+                      report_blocks: [ { source_ssrc: "\\d.*",</span><br><span>                                         highest_seq_no: "\\d.*",</span><br><span>                                         fraction_lost: 0,</span><br><span>                                         ia_jitter: "\\d.*",</span><br><span>@@ -180,7 +180,7 @@</span><br><span>                 value:</span><br><span>                     { ssrc: "\\d.*",</span><br><span>                       type: 201,</span><br><span style="color: hsl(0, 100%, 40%);">-                      report_blocks:[ { source_ssrc: "\\d.*",</span><br><span style="color: hsl(120, 100%, 40%);">+                      report_blocks: [ { source_ssrc: "\\d.*",</span><br><span>                                         highest_seq_no: "\\d.*",</span><br><span>                                         fraction_lost: 0,</span><br><span>                                         ia_jitter: "\\d.*",</span><br><span>diff --git a/tests/hep/rtcp-sender/test-config.yaml b/tests/hep/rtcp-sender/test-config.yaml</span><br><span>index c4e32c6..5083115 100644</span><br><span>--- a/tests/hep/rtcp-sender/test-config.yaml</span><br><span>+++ b/tests/hep/rtcp-sender/test-config.yaml</span><br><span>@@ -76,7 +76,7 @@</span><br><span>                                             ntp_timestamp_usec: "\\d.*",</span><br><span>                                             octets: "\\d.*",</span><br><span>                                             rtp_timestamp: "\\d.*", },</span><br><span style="color: hsl(0, 100%, 40%);">-                      report_blocks:[ { source_ssrc: "\\d.*",</span><br><span style="color: hsl(120, 100%, 40%);">+                      report_blocks: [ { source_ssrc: "\\d.*",</span><br><span>                                         highest_seq_no: "\\d.*",</span><br><span>                                         fraction_lost: 0,</span><br><span>                                         ia_jitter: "\\d.*",</span><br><span>@@ -103,7 +103,7 @@</span><br><span>                                             ntp_timestamp_usec: "\\d.*",</span><br><span>                                             octets: "\\d.*",</span><br><span>                                             rtp_timestamp: "\\d.*", },</span><br><span style="color: hsl(0, 100%, 40%);">-                      report_blocks:[ { source_ssrc: "\\d.*",</span><br><span style="color: hsl(120, 100%, 40%);">+                      report_blocks: [ { source_ssrc: "\\d.*",</span><br><span>                                         highest_seq_no: "\\d.*",</span><br><span>                                         fraction_lost: 0,</span><br><span>                                         ia_jitter: "\\d.*",</span><br><span>@@ -130,7 +130,7 @@</span><br><span>                                             ntp_timestamp_usec: "\\d.*",</span><br><span>                                             octets: "\\d.*",</span><br><span>                                             rtp_timestamp: "\\d.*", },</span><br><span style="color: hsl(0, 100%, 40%);">-                      report_blocks:[ { source_ssrc: "\\d.*",</span><br><span style="color: hsl(120, 100%, 40%);">+                      report_blocks: [ { source_ssrc: "\\d.*",</span><br><span>                                         highest_seq_no: "\\d.*",</span><br><span>                                         fraction_lost: 0,</span><br><span>                                         ia_jitter: "\\d.*",</span><br><span>@@ -157,7 +157,7 @@</span><br><span>                                             ntp_timestamp_usec: "\\d.*",</span><br><span>                                             octets: "\\d.*",</span><br><span>                                             rtp_timestamp: "\\d.*", },</span><br><span style="color: hsl(0, 100%, 40%);">-                      report_blocks:[ { source_ssrc: "\\d.*",</span><br><span style="color: hsl(120, 100%, 40%);">+                      report_blocks: [ { source_ssrc: "\\d.*",</span><br><span>                                         highest_seq_no: "\\d.*",</span><br><span>                                         fraction_lost: 0,</span><br><span>                                         ia_jitter: "\\d.*",</span><br><span>@@ -184,7 +184,7 @@</span><br><span>                                             ntp_timestamp_usec: "\\d.*",</span><br><span>                                             octets: "\\d.*",</span><br><span>                                             rtp_timestamp: "\\d.*", },</span><br><span style="color: hsl(0, 100%, 40%);">-                      report_blocks:[ { source_ssrc: "\\d.*",</span><br><span style="color: hsl(120, 100%, 40%);">+                      report_blocks: [ { source_ssrc: "\\d.*",</span><br><span>                                         highest_seq_no: "\\d.*",</span><br><span>                                         fraction_lost: 0,</span><br><span>                                         ia_jitter: "\\d.*",</span><br><span>@@ -211,7 +211,7 @@</span><br><span>                                             ntp_timestamp_usec: "\\d.*",</span><br><span>                                             octets: "\\d.*",</span><br><span>                                             rtp_timestamp: "\\d.*", },</span><br><span style="color: hsl(0, 100%, 40%);">-                      report_blocks:[ { source_ssrc: "\\d.*",</span><br><span style="color: hsl(120, 100%, 40%);">+                      report_blocks: [ { source_ssrc: "\\d.*",</span><br><span>                                         highest_seq_no: "\\d.*",</span><br><span>                                         fraction_lost: 0,</span><br><span>                                         ia_jitter: "\\d.*",</span><br><span>@@ -249,7 +249,7 @@</span><br><span>                                             ntp_timestamp_usec: "\\d.*",</span><br><span>                                             octets: "\\d.*",</span><br><span>                                             rtp_timestamp: "\\d.*", },</span><br><span style="color: hsl(0, 100%, 40%);">-                      report_blocks:[ { source_ssrc: "\\d.*",</span><br><span style="color: hsl(120, 100%, 40%);">+                      report_blocks: [ { source_ssrc: "\\d.*",</span><br><span>                                         highest_seq_no: "\\d.*",</span><br><span>                                         fraction_lost: 0,</span><br><span>                                         ia_jitter: "\\d.*",</span><br><span>@@ -276,7 +276,7 @@</span><br><span>                                             ntp_timestamp_usec: "\\d.*",</span><br><span>                                             octets: "\\d.*",</span><br><span>                                             rtp_timestamp: "\\d.*", },</span><br><span style="color: hsl(0, 100%, 40%);">-                      report_blocks:[ { source_ssrc: "\\d.*",</span><br><span style="color: hsl(120, 100%, 40%);">+                      report_blocks: [ { source_ssrc: "\\d.*",</span><br><span>                                         highest_seq_no: "\\d.*",</span><br><span>                                         fraction_lost: 0,</span><br><span>                                         ia_jitter: "\\d.*",</span><br><span>@@ -303,7 +303,7 @@</span><br><span>                                             ntp_timestamp_usec: "\\d.*",</span><br><span>                                             octets: "\\d.*",</span><br><span>                                             rtp_timestamp: "\\d.*", },</span><br><span style="color: hsl(0, 100%, 40%);">-                      report_blocks:[ { source_ssrc: "\\d.*",</span><br><span style="color: hsl(120, 100%, 40%);">+                      report_blocks: [ { source_ssrc: "\\d.*",</span><br><span>                                         highest_seq_no: "\\d.*",</span><br><span>                                         fraction_lost: 0,</span><br><span>                                         ia_jitter: "\\d.*",</span><br><span>@@ -330,7 +330,7 @@</span><br><span>                                             ntp_timestamp_usec: "\\d.*",</span><br><span>                                             octets: "\\d.*",</span><br><span>                                             rtp_timestamp: "\\d.*", },</span><br><span style="color: hsl(0, 100%, 40%);">-                      report_blocks:[ { source_ssrc: "\\d.*",</span><br><span style="color: hsl(120, 100%, 40%);">+                      report_blocks: [ { source_ssrc: "\\d.*",</span><br><span>                                         highest_seq_no: "\\d.*",</span><br><span>                                         fraction_lost: 0,</span><br><span>                                         ia_jitter: "\\d.*",</span><br><span>@@ -357,7 +357,7 @@</span><br><span>                                             ntp_timestamp_usec: "\\d.*",</span><br><span>                                             octets: "\\d.*",</span><br><span>                                             rtp_timestamp: "\\d.*", },</span><br><span style="color: hsl(0, 100%, 40%);">-                      report_blocks:[ { source_ssrc: "\\d.*",</span><br><span style="color: hsl(120, 100%, 40%);">+                      report_blocks: [ { source_ssrc: "\\d.*",</span><br><span>                                         highest_seq_no: "\\d.*",</span><br><span>                                         fraction_lost: 0,</span><br><span>                                         ia_jitter: "\\d.*",</span><br><span>@@ -384,7 +384,7 @@</span><br><span>                                             ntp_timestamp_usec: "\\d.*",</span><br><span>                                             octets: "\\d.*",</span><br><span>                                             rtp_timestamp: "\\d.*", },</span><br><span style="color: hsl(0, 100%, 40%);">-                      report_blocks:[ { source_ssrc: "\\d.*",</span><br><span style="color: hsl(120, 100%, 40%);">+                      report_blocks: [ { source_ssrc: "\\d.*",</span><br><span>                                         highest_seq_no: "\\d.*",</span><br><span>                                         fraction_lost: 0,</span><br><span>                                         ia_jitter: "\\d.*",</span><br><span>diff --git a/usage.py b/usage.py</span><br><span>index 5b12bdd..dd6facc 100755</span><br><span>--- a/usage.py</span><br><span>+++ b/usage.py</span><br><span>@@ -11,6 +11,11 @@</span><br><span> import sys</span><br><span> import yaml</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+try:</span><br><span style="color: hsl(120, 100%, 40%);">+    from yaml import CSafeLoader as MyLoader</span><br><span style="color: hsl(120, 100%, 40%);">+except ImportError:</span><br><span style="color: hsl(120, 100%, 40%);">+    from yaml import SafeLoader as MyLoader</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> sys.path.append('lib/python')</span><br><span> </span><br><span> TESTS_CONFIG = "tests.yaml"</span><br><span>@@ -101,7 +106,7 @@</span><br><span>         print("Unexpected error: %s" % sys.exc_info()[0])</span><br><span>         return None</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-    config = yaml.load(f, Loader=yaml.SafeLoader)</span><br><span style="color: hsl(120, 100%, 40%);">+    config = yaml.load(f, Loader=MyLoader)</span><br><span>     f.close()</span><br><span> </span><br><span>     return config</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/testsuite/+/13572">change 13572</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/testsuite/+/13572"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: testsuite </div>
<div style="display:none"> Gerrit-Branch: 17 </div>
<div style="display:none"> Gerrit-Change-Id: I4eb4b17d29e32e1ca7e1d260d7d0e59e4646a18e </div>
<div style="display:none"> Gerrit-Change-Number: 13572 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>