@@ -174,6 +174,21 @@ void test_filter_compile(std::shared_ptr<sinsp_filter_factory> factory,
174174 << " filter: " + filter_str + " \n actual warnings: " + warnings_fmt;
175175}
176176
177+ void test_filter_compile_msg (std::shared_ptr<sinsp_filter_factory> factory,
178+ const string& filter_str,
179+ const string& expected_msg) {
180+ sinsp_filter_compiler compiler (factory, filter_str);
181+ try {
182+ auto filter = compiler.compile ();
183+ (void )filter;
184+ FAIL () << filter_str << " -> expected failure but compilation was successful" ;
185+ } catch (const std::exception& e) {
186+ ASSERT_EQ (std::string (e.what ()), expected_msg) << " filter: " << filter_str;
187+ } catch (...) {
188+ FAIL () << filter_str << " -> " << " UNKNOWN ERROR" ;
189+ }
190+ }
191+
177192// In each of these test cases, we compile filter expression
178193// of which we can control the truth state of each filtercheck,
179194// so that we can deterministically check the result of running
@@ -631,6 +646,20 @@ TEST(sinsp_filter_compiler, compilation_warnings) {
631646 test_filter_compile (factory, " evt.source regex syscal[l]?" , false , 0 );
632647}
633648
649+ TEST (sinsp_filter_compiler, transformer_field_arg_support) {
650+ sinsp inspector;
651+ sinsp_filter_check_list filterlist;
652+ auto factory = std::make_shared<sinsp_filter_factory>(&inspector, filterlist);
653+
654+ test_filter_compile_msg (factory,
655+ R"( toupper(fd.name)[x] = foo)" ,
656+ " filter error: transformer 'toupper' does not support field "
657+ " arguments" );
658+ test_filter_compile_msg (factory,
659+ R"( fd.name = val(proc.name)[x])" ,
660+ " filter error: transformer 'val' does not support field arguments" );
661+ }
662+
634663// ////////////////////////////
635664// Test filter strings against real events.
636665// ////////////////////////////
0 commit comments