<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
- <classpathentry combineaccessrules="false" kind="src" path="/lttng-ust-agent-jul"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
- <classpathentry combineaccessrules="false" kind="src" path="/lttng-ust-agent-common"/>
- <classpathentry kind="lib" path="/usr/share/java/log4j-1.2.jar"/>
- <classpathentry combineaccessrules="false" kind="src" path="/lttng-ust-agent-log4j"/>
- <classpathentry kind="output" path="bin"/>
+ <classpathentry kind="src" output="target/classes" path="src/main/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>ust-java-tests</name>
+ <name>lttng-ust-agent-tests</name>
<comment></comment>
<projects>
</projects>
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
--- /dev/null
+eclipse.preferences.version=1
+encoding//src/test/java=UTF-8
+encoding/<project>=UTF-8
eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=warning
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=warning
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=warning
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=warning
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=warning
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=disabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=disabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
-org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
-org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
-org.eclipse.jdt.core.formatter.alignment_for_assignment=0
-org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
-org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
-org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
-org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
-org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
-org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
-org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
-org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
-org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
-org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
-org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
-org.eclipse.jdt.core.formatter.blank_lines_after_package=1
-org.eclipse.jdt.core.formatter.blank_lines_before_field=0
-org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
-org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
-org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
-org.eclipse.jdt.core.formatter.blank_lines_before_method=1
-org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
-org.eclipse.jdt.core.formatter.blank_lines_before_package=0
-org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
-org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
-org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
-org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
-org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
-org.eclipse.jdt.core.formatter.comment.format_block_comments=true
-org.eclipse.jdt.core.formatter.comment.format_header=false
-org.eclipse.jdt.core.formatter.comment.format_html=true
-org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
-org.eclipse.jdt.core.formatter.comment.format_line_comments=true
-org.eclipse.jdt.core.formatter.comment.format_source_code=true
-org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
-org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
-org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
-org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
-org.eclipse.jdt.core.formatter.comment.line_length=80
-org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
-org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
-org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
-org.eclipse.jdt.core.formatter.compact_else_if=true
-org.eclipse.jdt.core.formatter.continuation_indentation=2
-org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
-org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
-org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
-org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
-org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
-org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
-org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
-org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
-org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
-org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
-org.eclipse.jdt.core.formatter.indent_empty_lines=false
-org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
-org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
-org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
-org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
-org.eclipse.jdt.core.formatter.indentation.size=4
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
-org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
-org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
-org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
-org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
-org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
-org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
-org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
-org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
-org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
-org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
-org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
-org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
-org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
-org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
-org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
-org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
-org.eclipse.jdt.core.formatter.join_lines_in_comments=true
-org.eclipse.jdt.core.formatter.join_wrapped_lines=false
-org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
-org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
-org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
-org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
-org.eclipse.jdt.core.formatter.lineSplit=120
-org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
-org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
-org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
-org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
-org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
-org.eclipse.jdt.core.formatter.tabulation.char=space
-org.eclipse.jdt.core.formatter.tabulation.size=4
-org.eclipse.jdt.core.formatter.use_on_off_tags=false
-org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=true
-org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
-org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
-org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
-org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter
+++ /dev/null
-eclipse.preferences.version=1
-editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
-formatter_profile=_Spaces
-formatter_settings_version=12
-sp_cleanup.add_default_serial_version_id=true
-sp_cleanup.add_generated_serial_version_id=false
-sp_cleanup.add_missing_annotations=false
-sp_cleanup.add_missing_deprecated_annotations=true
-sp_cleanup.add_missing_methods=false
-sp_cleanup.add_missing_nls_tags=false
-sp_cleanup.add_missing_override_annotations=true
-sp_cleanup.add_missing_override_annotations_interface_methods=true
-sp_cleanup.add_serial_version_id=false
-sp_cleanup.always_use_blocks=true
-sp_cleanup.always_use_parentheses_in_expressions=false
-sp_cleanup.always_use_this_for_non_static_field_access=false
-sp_cleanup.always_use_this_for_non_static_method_access=false
-sp_cleanup.convert_functional_interfaces=false
-sp_cleanup.convert_to_enhanced_for_loop=false
-sp_cleanup.correct_indentation=false
-sp_cleanup.format_source_code=false
-sp_cleanup.format_source_code_changes_only=false
-sp_cleanup.insert_inferred_type_arguments=false
-sp_cleanup.make_local_variable_final=true
-sp_cleanup.make_parameters_final=false
-sp_cleanup.make_private_fields_final=true
-sp_cleanup.make_type_abstract_if_missing_method=false
-sp_cleanup.make_variable_declarations_final=false
-sp_cleanup.never_use_blocks=false
-sp_cleanup.never_use_parentheses_in_expressions=true
-sp_cleanup.on_save_use_additional_actions=true
-sp_cleanup.organize_imports=false
-sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
-sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
-sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
-sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
-sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
-sp_cleanup.remove_private_constructors=true
-sp_cleanup.remove_redundant_type_arguments=true
-sp_cleanup.remove_trailing_whitespaces=true
-sp_cleanup.remove_trailing_whitespaces_all=true
-sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
-sp_cleanup.remove_unnecessary_casts=false
-sp_cleanup.remove_unnecessary_nls_tags=false
-sp_cleanup.remove_unused_imports=false
-sp_cleanup.remove_unused_local_variables=false
-sp_cleanup.remove_unused_private_fields=true
-sp_cleanup.remove_unused_private_members=false
-sp_cleanup.remove_unused_private_methods=true
-sp_cleanup.remove_unused_private_types=true
-sp_cleanup.sort_members=false
-sp_cleanup.sort_members_all=false
-sp_cleanup.use_anonymous_class_creation=false
-sp_cleanup.use_blocks=false
-sp_cleanup.use_blocks_only_for_return_and_throw=false
-sp_cleanup.use_lambda=true
-sp_cleanup.use_parentheses_in_expressions=false
-sp_cleanup.use_this_for_non_static_field_access=false
-sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
-sp_cleanup.use_this_for_non_static_method_access=false
-sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
-sp_cleanup.use_type_arguments=false
--- /dev/null
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (C) 2015, EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; only
+ version 2.1 of the License.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.lttng.ust.agent</groupId>
+ <artifactId>lttng-ust-agent-tests</artifactId>
+ <version>1.0.0</version>
+ <packaging>jar</packaging>
+
+ <name>LTTng-UST Java Agent Test Suite</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <!-- Paths that come from UST's default "make install".
+ Override to specify other locations. -->
+ <common-jar-location>/usr/local/share/java/lttng-ust-agent-common-1.0.0.jar</common-jar-location>
+ <jul-jar-location>/usr/local/share/java/lttng-ust-agent-jul-1.0.0.jar</jul-jar-location>
+ <log4j-jar-location>/usr/local/share/java/lttng-ust-agent-log4j-1.0.0.jar</log4j-jar-location>
+ <argLine>-Djava.library.path=/usr/local/lib</argLine>
+ </properties>
+
+ <dependencies>
+ <!-- System dependencies, should have been installed by UST -->
+ <dependency>
+ <groupId>org.lttng.ust.agent</groupId>
+ <artifactId>lttng-ust-agent-common</artifactId>
+ <version>1.0.0</version>
+ <scope>system</scope>
+ <systemPath>${common-jar-location}</systemPath>
+ </dependency>
+ <dependency>
+ <groupId>org.lttng.ust.agent</groupId>
+ <artifactId>lttng-ust-agent-jul</artifactId>
+ <version>1.0.0</version>
+ <scope>system</scope>
+ <systemPath>${jul-jar-location}</systemPath>
+ </dependency>
+ <dependency>
+ <groupId>org.lttng.ust.agent</groupId>
+ <artifactId>lttng-ust-agent-log4j</artifactId>
+ <version>1.0.0</version>
+ <scope>system</scope>
+ <systemPath>${log4j-jar-location}</systemPath>
+ </dependency>
+
+ <!-- "Real" Maven dependencies -->
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.17</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
+++ /dev/null
-package org.lttng.ust.agent.benchmarks.jul;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- org.lttng.ust.agent.benchmarks.jul.handler.NoHandlerBenchmark.class,
- org.lttng.ust.agent.benchmarks.jul.handler.DummyHandlerBenchmark.class,
-// org.lttng.ust.agent.jul.benchmarks.handler.FileHandlerBenchmark.class,
- org.lttng.ust.agent.benchmarks.jul.handler.lttng.LttngJulHandlerTracingDisabledBenchmark.class,
- org.lttng.ust.agent.benchmarks.jul.handler.lttng.LttngJulHandlerTracingEnabledBenchmark.class,
- org.lttng.ust.agent.benchmarks.jul.handler.lttng.old.OldLttngJulHandlerTracingDisabledBenchmark.class,
- org.lttng.ust.agent.benchmarks.jul.handler.lttng.old.OldLttngJulHandlerTracingEnabledBenchmark.class
-})
-public class RunAllJulBenchmarks {
-}
+++ /dev/null
-package org.lttng.ust.agent.benchmarks.jul.handler;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public abstract class AbstractJulBenchmark {
-
- // ------------------------------------------------------------------------
- // Configurable test parameters
- // ------------------------------------------------------------------------
-
- /** Nb of runs per test, result will be averaged */
- private static final int NB_RUNS = 10;
-
- /** Trace/log events per run */
- private static final int NB_ITER = 100000;
-
- /** Which tests to run (for different number of threads) */
- private static final int[] NB_THREADS = {1, 1, 2, 3, 4, 5, 6, 7, 8};
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- protected Logger logger;
- protected Handler handler;
-
- // ------------------------------------------------------------------------
- // Maintenance methods
- // ------------------------------------------------------------------------
-
- @Before
- public void setup() {
- /* Set up the logger */
- logger = Logger.getLogger("Test logger");
- logger.setUseParentHandlers(false);
- logger.setLevel(Level.ALL);
-
- /* Sub-classes' @Before will setup the Handler */
- }
-
- @After
- public void teardown() {
- if (handler != null) {
- logger.removeHandler(handler);
- handler.close();
- }
- handler = null;
- logger = null;
- }
-
- // ------------------------------------------------------------------------
- // Test methods
- // ------------------------------------------------------------------------
-
- @Test
- public void runBenchmark() {
- if (handler != null) {
- logger.addHandler(handler);
- }
-
- System.out.println();
- System.out.println("Running benchmark: " + this.getClass().getCanonicalName());
- for (int i : NB_THREADS) {
- runTest(logger, i);
- }
- }
-
- private static void runTest(Logger log, int nbThreads) {
- long start, end, average, total = 0;
- for (int i = 0; i < NB_RUNS; i++) {
- Runner runner = new Runner(nbThreads, NB_ITER, log);
-
- start = System.nanoTime();
- runner.run();
- end = System.nanoTime();
-
- total += (end - start);
- }
- average = total / NB_RUNS;
- System.out.println(nbThreads + " threads, average = " + average / NB_ITER + " ns/event");
- }
-
- // ------------------------------------------------------------------------
- // Helper classes
- // ------------------------------------------------------------------------
-
- private static class Runner implements Runnable {
-
- private final List<Worker> workers = new LinkedList<>();
- private final List<Thread> workerThreads = new LinkedList<>();
-
- public Runner(int nbThreads, int nbIter, Logger log) {
-
- for (int id = 0; id < nbThreads; id++) {
- Worker curWorker = new Worker(id, nbIter, log);
- workers.add(curWorker);
- workerThreads.add(new Thread(curWorker, "worker " + id));
- }
- }
-
- @Override
- public void run() {
- for (Thread curThread : workerThreads) {
- curThread.start();
- }
-
- for (Thread curThread : workerThreads) {
- try {
- curThread.join();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
-
- private static class Worker implements Runnable {
-
- private final Logger log;
- private final int threadId;
- private final int nbIter;
-
- public Worker(int threadId, int nbIter, Logger log) {
- this.log = log;
- this.threadId = threadId;
- this.nbIter = nbIter;
- }
-
- @Override
- public void run() {
- for (int i = 0; i < nbIter; i++) {
- log.info("Thread " + threadId + ", iteration " + i);
- }
- }
-
- }
- }
-}
+++ /dev/null
-package org.lttng.ust.agent.benchmarks.jul.handler;
-
-import java.util.logging.Handler;
-import java.util.logging.LogRecord;
-
-import org.junit.Before;
-
-public class DummyHandlerBenchmark extends AbstractJulBenchmark {
-
- @Before
- public void testSetup() {
- handler = new DummyHandler();
- }
-
- private static class DummyHandler extends Handler {
-
- public DummyHandler() {
- super();
- }
-
- @Override
- public void close() throws SecurityException {}
-
- @Override
- public void flush() {}
-
- @Override
- public void publish(LogRecord record) {}
-
- }
-}
+++ /dev/null
-package org.lttng.ust.agent.benchmarks.jul.handler;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.logging.FileHandler;
-import java.util.logging.SimpleFormatter;
-
-import org.junit.After;
-import org.junit.Before;
-
-public class FileHandlerBenchmark extends AbstractJulBenchmark {
-
- private Path outputFile;
-
- @Before
- public void testSetup() throws SecurityException, IOException {
- outputFile = Files.createTempFile(this.getClass().getSimpleName(), null);
-
- handler = new FileHandler(outputFile.toString(), false);
- handler.setFormatter(new SimpleFormatter());
- }
-
- @After
- public void testTeardown() throws IOException {
- Files.deleteIfExists(outputFile);
- }
-}
+++ /dev/null
-package org.lttng.ust.agent.benchmarks.jul.handler;
-
-public class NoHandlerBenchmark extends AbstractJulBenchmark {
-
- /* Do not setup any handler */
-}
+++ /dev/null
-package org.lttng.ust.agent.benchmarks.jul.handler.lttng;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-
-import org.junit.After;
-import org.junit.Before;
-import org.lttng.ust.agent.benchmarks.jul.handler.AbstractJulBenchmark;
-import org.lttng.ust.agent.jul.LttngLogHandler;
-import org.lttng.ust.agent.utils.LttngSession;
-import org.lttng.ust.agent.utils.LttngSession.Domain;
-
-public class LttngJulHandlerTracingDisabledBenchmark extends AbstractJulBenchmark {
-
- private LttngSession session;
-
- @Before
- public void testSetup() throws IOException {
- handler = new LttngLogHandler();
-
- session = new LttngSession(null, Domain.JUL);
- assertTrue(session.enableEvents("non-event"));
- assertTrue(session.start());
- }
-
- @After
- public void testTeardown() {
- assertTrue(session.stop());
- session.close();
- }
-}
+++ /dev/null
-package org.lttng.ust.agent.benchmarks.jul.handler.lttng;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-
-import org.junit.After;
-import org.junit.Before;
-import org.lttng.ust.agent.benchmarks.jul.handler.AbstractJulBenchmark;
-import org.lttng.ust.agent.jul.LttngLogHandler;
-import org.lttng.ust.agent.utils.LttngSession;
-import org.lttng.ust.agent.utils.LttngSession.Domain;
-
-public class LttngJulHandlerTracingEnabledBenchmark extends AbstractJulBenchmark {
-
- private LttngSession session;
-
- @Before
- public void testSetup() throws IOException {
- handler = new LttngLogHandler();
-
- session = new LttngSession(null, Domain.JUL);
- assertTrue(session.enableAllEvents());
- assertTrue(session.start());
- }
-
- @After
- public void testTeardown() {
- assertTrue(session.stop());
- session.close();
- }
-}
+++ /dev/null
-package org.lttng.ust.agent.benchmarks.jul.handler.lttng.old;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.After;
-import org.junit.Before;
-import org.lttng.ust.agent.LTTngAgent;
-import org.lttng.ust.agent.benchmarks.jul.handler.AbstractJulBenchmark;
-import org.lttng.ust.agent.utils.LttngSession;
-import org.lttng.ust.agent.utils.LttngSession.Domain;
-
-@SuppressWarnings("deprecation")
-public class OldLttngJulHandlerTracingDisabledBenchmark extends AbstractJulBenchmark {
-
- private LttngSession session;
-
- @Before
- public void testSetup() {
- LTTngAgent.getLTTngAgent();
-
- session = new LttngSession(null, Domain.JUL);
- assertTrue(session.enableEvents("non-event"));
- assertTrue(session.start());
- }
-
- @After
- public void testTeardown() {
- assertTrue(session.stop());
- session.close();
-
- LTTngAgent.dispose();
- }
-}
+++ /dev/null
-package org.lttng.ust.agent.benchmarks.jul.handler.lttng.old;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.lang.reflect.Field;
-
-import org.junit.After;
-import org.junit.Before;
-import org.lttng.ust.agent.LTTngAgent;
-import org.lttng.ust.agent.benchmarks.jul.handler.AbstractJulBenchmark;
-import org.lttng.ust.agent.jul.LttngLogHandler;
-import org.lttng.ust.agent.utils.LttngSession;
-import org.lttng.ust.agent.utils.LttngSession.Domain;
-
-@SuppressWarnings("deprecation")
-public class OldLttngJulHandlerTracingEnabledBenchmark extends AbstractJulBenchmark {
-
- private LttngSession session;
- private LttngLogHandler agentHandler;
-
- @Before
- public void testSetup() {
- LTTngAgent agentInstance = LTTngAgent.getLTTngAgent();
-
- /*
- * The "old API" works by attaching a handler managed by the agent to
- * the root JUL logger. This causes problems here, because we use
- * logger.setUserParentHandler(false), which does not trigger the
- * handler as would be expected.
- *
- * Instead we will retrieve this handler through reflection, and attach
- * it to our own logger here for the duration of the test.
- */
- try {
- Field julHandlerField = LTTngAgent.class.getDeclaredField("julHandler");
- julHandlerField.setAccessible(true);
- agentHandler = (LttngLogHandler) julHandlerField.get(agentInstance);
-
- logger.addHandler(agentHandler);
-
- } catch (ReflectiveOperationException e) {
- fail();
- }
-
- session = new LttngSession(null, Domain.JUL);
- assertTrue(session.enableAllEvents());
- assertTrue(session.start());
- }
-
- @After
- public void testTeardown() {
- assertTrue(session.stop());
- session.close();
-
- logger.removeHandler(agentHandler);
- LTTngAgent.dispose();
- }
-}
+++ /dev/null
-package org.lttng.ust.agent.integration;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- org.lttng.ust.agent.integration.jul.AllTests.class,
- org.lttng.ust.agent.integration.log4j.AllTests.class,
-})
-public class RunAllIntegrationTests {
-
-}
+++ /dev/null
-package org.lttng.ust.agent.integration.common;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.lttng.ust.agent.ILttngHandler;
-import org.lttng.ust.agent.utils.LttngSession;
-import org.lttng.ust.agent.utils.LttngSession.Domain;
-
-public abstract class EnabledEventsTest {
-
- protected static final String EVENT_NAME_A = "EventA";
- protected static final String EVENT_NAME_B = "EventAB";
- protected static final String EVENT_NAME_C = "EventABC";
- protected static final String EVENT_NAME_D = "EventABCD";
-
- private LttngSession session;
-
- /* Fields defined by the sub-class */
- protected ILttngHandler handlerA;
- protected ILttngHandler handlerB;
- protected ILttngHandler handlerC;
-
- protected abstract Domain getDomain();
-
- protected abstract void sendEventsToLoggers();
-
- @Before
- public void testSetup() {
- session = new LttngSession(null, getDomain());
- }
-
- @After
- public void testTeardown() {
- session.close();
-
- handlerA.close();
- handlerB.close();
- handlerC.close();
-
- handlerA = null;
- handlerB = null;
- handlerC = null;
- }
-
- /**
- * Test sending events on the Java side, but no events enabled in the
- * tracing session. There should be nothing in the resulting trace, and
- * handlers should not have logged anything.
- */
- @Test
- public void testNoEvents() {
- assertTrue(session.start());
-
- sendEventsToLoggers();
-
- assertTrue(session.stop());
-
- List<String> output = session.view();
- assertNotNull(output);
- assertTrue(output.isEmpty());
-
- assertEquals(0, handlerA.getEventCount());
- assertEquals(0, handlerB.getEventCount());
- assertEquals(0, handlerC.getEventCount());
- }
-
- /**
- * Test sending events on the Java side, and all events enabled in the
- * tracing session. All handlers should have sent their events.
- */
- @Test
- public void testAllEvents() {
- assertTrue(session.enableAllEvents());
- assertTrue(session.start());
-
- sendEventsToLoggers();
-
- assertTrue(session.stop());
-
- List<String> output = session.view();
- assertNotNull(output);
- assertEquals(30, output.size()); // loggerD has no handler attached
-
- assertEquals(10, handlerA.getEventCount());
- assertEquals(10, handlerB.getEventCount());
- assertEquals(10, handlerC.getEventCount());
- }
-
- /**
- * Test sending events on the Java side, with only some of them enabled in
- * the tracing session. Only the subset that is enabled should be received.
- */
- @Test
- public void testSomeEvents() {
- assertTrue(session.enableEvents(EVENT_NAME_A, EVENT_NAME_C, EVENT_NAME_D));
- assertTrue(session.start());
-
- sendEventsToLoggers();
-
- assertTrue(session.stop());
-
- List<String> output = session.view();
- assertNotNull(output);
- assertEquals(20, output.size());
-
- assertEquals(10, handlerA.getEventCount());
- assertEquals(0, handlerB.getEventCount());
- assertEquals(10, handlerC.getEventCount());
- }
-
- /**
- * Test with all events enabled (-a), plus some other events added manually.
- * Events should still be retained, but there should be no duplicates.
- */
- @Test
- public void testAllEventsAndSome() {
- assertTrue(session.enableAllEvents());
- assertTrue(session.enableEvents(EVENT_NAME_A, EVENT_NAME_B));
- assertTrue(session.start());
-
- sendEventsToLoggers();
-
- assertTrue(session.stop());
-
- List<String> output = session.view();
- assertNotNull(output);
- assertEquals(30, output.size());
-
- assertEquals(10, handlerA.getEventCount());
- assertEquals(10, handlerB.getEventCount());
- assertEquals(10, handlerC.getEventCount());
- }
-
- /**
- * Same as {@link #testSomeEvents()}, but some events were enabled first,
- * then disabled. Makes sure the enabled-event refcounting works properly.
- */
- @Test
- public void testSomeEventsAfterDisabling() {
- assertTrue(session.enableEvents(EVENT_NAME_A, EVENT_NAME_C, EVENT_NAME_D));
- assertTrue(session.disableEvents(EVENT_NAME_C));
- assertTrue(session.start());
-
- sendEventsToLoggers();
-
- assertTrue(session.stop());
-
- List<String> output = session.view();
- assertNotNull(output);
- assertEquals(10, output.size());
-
- assertEquals(10, handlerA.getEventCount());
- assertEquals(0, handlerB.getEventCount());
- assertEquals(0, handlerC.getEventCount());
- }
-
- /**
- * Test enabling an event prefix, which means an event name ending with a *,
- * to match all events starting with this name.
- */
- @Test
- public void testEventPrefix() {
- // should match event/loggers B and C, but not A.
- assertTrue(session.enableEvents("EventAB*"));
- assertTrue(session.start());
-
- sendEventsToLoggers();
-
- assertTrue(session.stop());
-
- List<String> output = session.view();
- assertNotNull(output);
- assertEquals(20, output.size());
-
- assertEquals(0, handlerA.getEventCount());
- assertEquals(10, handlerB.getEventCount());
- assertEquals(10, handlerC.getEventCount());
- }
-
- /**
- * Same as {@link #testEventPrefix()}, but with multiple prefixes that
- * overlap. There should not be any duplicate events in the trace or in the
- * handlers.
- */
- @Test
- public void testEventPrefixOverlapping() {
- // should still match B and C
- assertTrue(session.enableEvents("EventAB*", "EventABC*"));
- assertTrue(session.start());
-
- sendEventsToLoggers();
-
- assertTrue(session.stop());
-
- List<String> output = session.view();
- assertNotNull(output);
- assertEquals(20, output.size());
-
- assertEquals(0, handlerA.getEventCount());
- assertEquals(10, handlerB.getEventCount());
- assertEquals(10, handlerC.getEventCount());
- }
-
- /**
- * Test with all events enabled (-a), plus an event prefix. Once again,
- * there should be no duplicates.
- */
- @Test
- public void testAllEventsAndPrefix() {
- assertTrue(session.enableAllEvents());
- assertTrue(session.enableEvents("EventAB*"));
- assertTrue(session.start());
-
- sendEventsToLoggers();
-
- assertTrue(session.stop());
-
- List<String> output = session.view();
- assertNotNull(output);
- assertEquals(30, output.size());
-
- assertEquals(10, handlerA.getEventCount());
- assertEquals(10, handlerB.getEventCount());
- assertEquals(10, handlerC.getEventCount());
- }
-}
+++ /dev/null
-package org.lttng.ust.agent.integration.common;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.lttng.ust.agent.ILttngHandler;
-import org.lttng.ust.agent.utils.LttngSession;
-import org.lttng.ust.agent.utils.LttngSession.Domain;
-
-/**
- * Tests with multiple concurrent tracing sessions
- */
-public abstract class MultiSessionTest {
-
- protected static final String EVENT_NAME_A = "EventA";
- protected static final String EVENT_NAME_B = "EventAB";
- protected static final String EVENT_NAME_C = "EventABC";
- protected static final String EVENT_NAME_D = "EventABCD";
-
- private LttngSession session1;
- private LttngSession session2;
- private LttngSession session3;
-
- /* Fields defined by the sub-class */
- protected ILttngHandler handlerA;
- protected ILttngHandler handlerB;
- protected ILttngHandler handlerC;
- protected ILttngHandler handlerD;
-
- protected abstract Domain getDomain();
-
- protected abstract void sendEventsToLoggers();
-
- @Before
- public void testSetup() {
- session1 = new LttngSession(null, getDomain());
- session2 = new LttngSession(null, getDomain());
- session3 = new LttngSession(null, getDomain());
- }
-
- @After
- public void testTeardown() {
- session1.close();
- session2.close();
- session3.close();
-
- handlerA.close();
- handlerB.close();
- handlerC.close();
- handlerD.close();
-
- handlerA = null;
- handlerB = null;
- handlerC = null;
- handlerD = null;
- }
-
- /**
- * Test with no events in any session.
- */
- @Test
- public void testNoEvents() {
- assertTrue(session1.start());
- assertTrue(session2.start());
- assertTrue(session3.start());
-
- sendEventsToLoggers();
-
- assertTrue(session1.stop());
- assertTrue(session2.stop());
- assertTrue(session3.stop());
-
- List<String> output1 = session1.view();
- List<String> output2 = session2.view();
- List<String> output3 = session3.view();
- assertNotNull(output1);
- assertNotNull(output2);
- assertNotNull(output3);
- assertTrue(output1.isEmpty());
- assertTrue(output2.isEmpty());
- assertTrue(output3.isEmpty());
-
- assertEquals(0, handlerA.getEventCount());
- assertEquals(0, handlerB.getEventCount());
- assertEquals(0, handlerC.getEventCount());
- assertEquals(0, handlerD.getEventCount());
- }
-
- /**
- * Test with all events enabled in one session only. Everything should be
- * sent through JNI, but only that session should keep the trace events.
- */
- @Test
- public void testAllEventsOneSession() {
- assertTrue(session1.enableAllEvents());
- assertTrue(session1.start());
- assertTrue(session2.start());
- assertTrue(session3.start());
-
- sendEventsToLoggers();
-
- assertTrue(session1.stop());
- assertTrue(session2.stop());
- assertTrue(session3.stop());
-
- List<String> output1 = session1.view();
- List<String> output2 = session2.view();
- List<String> output3 = session3.view();
- assertNotNull(output1);
- assertNotNull(output2);
- assertNotNull(output3);
- assertEquals(40, output1.size());
- assertTrue(output2.isEmpty());
- assertTrue(output3.isEmpty());
-
- assertEquals(10, handlerA.getEventCount());
- assertEquals(10, handlerB.getEventCount());
- assertEquals(10, handlerC.getEventCount());
- assertEquals(10, handlerD.getEventCount());
- }
-
- /**
- * Test with all events enabled in all sessions. All traces and handlers
- * should see every event that was logged.
- */
- @Test
- public void testAllEventsAllSessions() {
- assertTrue(session1.enableAllEvents());
- assertTrue(session2.enableAllEvents());
- assertTrue(session3.enableAllEvents());
- assertTrue(session1.start());
- assertTrue(session2.start());
- assertTrue(session3.start());
-
- sendEventsToLoggers();
-
- assertTrue(session1.stop());
- assertTrue(session2.stop());
- assertTrue(session3.stop());
-
- List<String> output1 = session1.view();
- List<String> output2 = session2.view();
- List<String> output3 = session3.view();
- assertNotNull(output1);
- assertNotNull(output2);
- assertNotNull(output3);
- assertEquals(40, output1.size());
- assertEquals(40, output2.size());
- assertEquals(40, output3.size());
-
- assertEquals(10, handlerA.getEventCount());
- assertEquals(10, handlerB.getEventCount());
- assertEquals(10, handlerC.getEventCount());
- assertEquals(10, handlerD.getEventCount());
- }
-
- /**
- * Test enabling some events in some sessions only.
- */
- @Test
- public void testSomeEvents() {
- assertTrue(session1.enableEvents(EVENT_NAME_A));
- assertTrue(session2.enableEvents(EVENT_NAME_B));
- assertTrue(session1.start());
- assertTrue(session2.start());
- assertTrue(session3.start());
-
- sendEventsToLoggers();
-
- assertTrue(session1.stop());
- assertTrue(session2.stop());
- assertTrue(session3.stop());
-
- List<String> output1 = session1.view();
- List<String> output2 = session2.view();
- List<String> output3 = session3.view();
- assertNotNull(output1);
- assertNotNull(output2);
- assertNotNull(output3);
- assertEquals(10, output1.size());
- assertEquals(10, output2.size());
- assertEquals(0, output3.size());
-
- assertEquals(10, handlerA.getEventCount());
- assertEquals(10, handlerB.getEventCount());
- assertEquals(0, handlerC.getEventCount());
- assertEquals(0, handlerD.getEventCount());
- }
-
- /**
- * Test with all events enabled in one session, and some others in another.
- * All events should arrive where expected, with no duplicates.
- */
- @Test
- public void testAllEventsAndSome() {
- assertTrue(session1.enableAllEvents());
- assertTrue(session2.enableEvents(EVENT_NAME_D));
- assertTrue(session1.start());
- assertTrue(session2.start());
- assertTrue(session3.start());
-
- sendEventsToLoggers();
-
- assertTrue(session1.stop());
- assertTrue(session2.stop());
- assertTrue(session3.stop());
-
- List<String> output1 = session1.view();
- List<String> output2 = session2.view();
- List<String> output3 = session3.view();
- assertNotNull(output1);
- assertNotNull(output2);
- assertNotNull(output3);
- assertEquals(40, output1.size());
- assertEquals(10, output2.size());
- assertEquals(0, output3.size());
-
- assertEquals(10, handlerA.getEventCount());
- assertEquals(10, handlerB.getEventCount());
- assertEquals(10, handlerC.getEventCount());
- assertEquals(10, handlerD.getEventCount());
- }
-
- /**
- * Test with enabling then disabling some events. Makes sure the refcounting
- * works properly.
- */
- @Test
- public void testSomeEventsAfterDisabling() {
- assertTrue(session1.enableEvents(EVENT_NAME_A, EVENT_NAME_B, EVENT_NAME_C));
- assertTrue(session2.enableEvents(EVENT_NAME_B, EVENT_NAME_C, EVENT_NAME_D));
- assertTrue(session3.enableEvents(EVENT_NAME_A));
-
- assertTrue(session1.disableEvents(EVENT_NAME_C));
- assertTrue(session2.disableEvents(EVENT_NAME_B, EVENT_NAME_C));
- assertTrue(session3.disableEvents(EVENT_NAME_A));
-
- assertTrue(session1.start());
- assertTrue(session2.start());
- assertTrue(session3.start());
-
- sendEventsToLoggers();
-
- assertTrue(session1.stop());
- assertTrue(session2.stop());
- assertTrue(session3.stop());
-
- List<String> output1 = session1.view();
- List<String> output2 = session2.view();
- List<String> output3 = session3.view();
- assertNotNull(output1);
- assertNotNull(output2);
- assertNotNull(output3);
- assertEquals(20, output1.size());
- assertEquals(10, output2.size());
- assertEquals(0, output3.size());
-
- assertEquals(10, handlerA.getEventCount());
- assertEquals(10, handlerB.getEventCount());
- assertEquals(0, handlerC.getEventCount());
- assertEquals(10, handlerD.getEventCount());
- }
-
- /**
- * Test with a prefix in one session and a standard event in another.
- */
- @Test
- public void testPrefixAndEvent() {
- assertTrue(session1.enableEvents("EventAB*"));
- assertTrue(session3.enableEvents(EVENT_NAME_A));
- assertTrue(session1.start());
- assertTrue(session2.start());
- assertTrue(session3.start());
-
- sendEventsToLoggers();
-
- assertTrue(session1.stop());
- assertTrue(session2.stop());
- assertTrue(session3.stop());
-
- List<String> output1 = session1.view();
- List<String> output2 = session2.view();
- List<String> output3 = session3.view();
- assertNotNull(output1);
- assertNotNull(output2);
- assertNotNull(output3);
- assertEquals(30, output1.size());
- assertEquals(0, output2.size());
- assertEquals(10, output3.size());
-
- assertEquals(10, handlerA.getEventCount());
- assertEquals(10, handlerB.getEventCount());
- assertEquals(10, handlerC.getEventCount());
- assertEquals(10, handlerD.getEventCount());
- }
-
- /**
- * Test with all events enabled in one session, and an event prefix in
- * another. Once again, there should be no duplicates.
- */
- @Test
- public void testAllEventsAndPrefix() {
- assertTrue(session1.enableAllEvents());
- assertTrue(session2.enableEvents("EventABC*"));
- assertTrue(session1.start());
- assertTrue(session2.start());
- assertTrue(session3.start());
-
- sendEventsToLoggers();
-
- assertTrue(session1.stop());
- assertTrue(session2.stop());
- assertTrue(session3.stop());
-
- List<String> output1 = session1.view();
- List<String> output2 = session2.view();
- List<String> output3 = session3.view();
- assertNotNull(output1);
- assertNotNull(output2);
- assertNotNull(output3);
- assertEquals(40, output1.size());
- assertEquals(20, output2.size());
- assertEquals(0, output3.size());
-
- assertEquals(10, handlerA.getEventCount());
- assertEquals(10, handlerB.getEventCount());
- assertEquals(10, handlerC.getEventCount());
- assertEquals(10, handlerD.getEventCount());
- }
-}
+++ /dev/null
-package org.lttng.ust.agent.integration.jul;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- JulEnabledEventsTest.class,
- JulLegacyApiTest.class,
- JulMultiSessionTest.class
-})
-public class AllTests {
-
-}
+++ /dev/null
-package org.lttng.ust.agent.integration.jul;
-
-import static org.junit.Assume.assumeTrue;
-
-import java.io.IOException;
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.lttng.ust.agent.integration.common.EnabledEventsTest;
-import org.lttng.ust.agent.jul.LttngLogHandler;
-import org.lttng.ust.agent.utils.LttngSession;
-import org.lttng.ust.agent.utils.LttngSession.Domain;
-import org.lttng.ust.agent.utils.TestUtils;
-
-public class JulEnabledEventsTest extends EnabledEventsTest {
-
- private static final Domain DOMAIN = Domain.JUL;
-
- private Logger loggerA;
- private Logger loggerB;
- private Logger loggerC;
- private Logger loggerD;
-
- @BeforeClass
- public static void julClassSetup() {
- /* Skip tests if we can't find the JNI library or lttng-tools */
- assumeTrue(TestUtils.checkForJulLibrary());
- assumeTrue(TestUtils.checkForLttngTools(Domain.JUL));
-
- LttngSession.destroyAllSessions();
- }
-
- @AfterClass
- public static void julClassCleanup() {
- LttngSession.deleteAllTracee();
- }
-
- @Before
- public void julSetup() throws SecurityException, IOException {
- loggerA = Logger.getLogger(EVENT_NAME_A);
- loggerB = Logger.getLogger(EVENT_NAME_B);
- loggerC = Logger.getLogger(EVENT_NAME_C);
- loggerD = Logger.getLogger(EVENT_NAME_D);
-
- loggerA.setLevel(Level.ALL);
- loggerB.setLevel(Level.ALL);
- loggerC.setLevel(Level.ALL);
- loggerD.setLevel(Level.ALL);
-
- handlerA = new LttngLogHandler();
- handlerB = new LttngLogHandler();
- handlerC = new LttngLogHandler();
-
- loggerA.addHandler((Handler) handlerA);
- loggerB.addHandler((Handler) handlerB);
- loggerC.addHandler((Handler) handlerC);
- }
-
- @After
- public void julTeardown() {
- loggerA.removeHandler((Handler) handlerA);
- loggerB.removeHandler((Handler) handlerB);
- loggerC.removeHandler((Handler) handlerC);
-
- loggerA = null;
- loggerB = null;
- loggerC = null;
- loggerD = null;
- }
-
- @Override
- protected Domain getDomain() {
- return DOMAIN;
- }
-
- @Override
- protected void sendEventsToLoggers() {
- JulTestUtils.send10EventsTo(loggerA);
- JulTestUtils.send10EventsTo(loggerB);
- JulTestUtils.send10EventsTo(loggerC);
- JulTestUtils.send10EventsTo(loggerD);
- }
-}
+++ /dev/null
-package org.lttng.ust.agent.integration.jul;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.junit.Assume.assumeTrue;
-
-import java.lang.reflect.Field;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.lttng.ust.agent.ILttngHandler;
-import org.lttng.ust.agent.LTTngAgent;
-import org.lttng.ust.agent.utils.LttngSession;
-import org.lttng.ust.agent.utils.LttngSession.Domain;
-import org.lttng.ust.agent.utils.TestUtils;
-
-@SuppressWarnings("deprecation")
-public class JulLegacyApiTest {
-
- private static final Domain DOMAIN = Domain.JUL;
-
- private static final String EVENT_NAME_A = "EventA";
- private static final String EVENT_NAME_B = "EventB";
-
- private LttngSession session;
-
- private Logger loggerA;
- private Logger loggerB;
-
- @BeforeClass
- public static void julClassSetup() {
- /* Skip tests if we can't find the JNI library or lttng-tools */
- assumeTrue(TestUtils.checkForJulLibrary());
- assumeTrue(TestUtils.checkForLttngTools(Domain.JUL));
-
- LttngSession.destroyAllSessions();
- }
-
- @AfterClass
- public static void julClassCleanup() {
- LttngSession.deleteAllTracee();
- }
-
- @Before
- public void setup() {
- loggerA = Logger.getLogger(EVENT_NAME_A);
- LTTngAgent.getLTTngAgent();
- loggerB = Logger.getLogger(EVENT_NAME_B);
-
- loggerA.setLevel(Level.ALL);
- loggerB.setLevel(Level.ALL);
-
- session = new LttngSession(null, DOMAIN);
- }
-
- @After
- public void tearDown() {
- session.close();
-
- LTTngAgent.dispose();
-
- loggerA = null;
- loggerB = null;
- }
-
- @Test
- public void testNoEvents() {
- assertTrue(session.start());
-
- JulTestUtils.send10EventsTo(loggerA);
- JulTestUtils.send10EventsTo(loggerB);
-
- assertTrue(session.stop());
-
- List<String> output = session.view();
- assertNotNull(output);
- assertTrue(output.isEmpty());
-
- ILttngHandler handler = getAgentHandler();
- assertEquals(0, handler.getEventCount());
- }
-
- @Test
- public void testAllEvents() {
- assertTrue(session.enableAllEvents());
- assertTrue(session.start());
-
- JulTestUtils.send10EventsTo(loggerA);
- JulTestUtils.send10EventsTo(loggerB);
-
- assertTrue(session.stop());
-
- List<String> output = session.view();
- assertNotNull(output);
- assertEquals(20, output.size());
-
- ILttngHandler handler = getAgentHandler();
- assertEquals(20, handler.getEventCount());
- }
-
- @Test
- public void testSomeEvents() {
- assertTrue(session.enableEvents(EVENT_NAME_A));
- assertTrue(session.start());
-
- JulTestUtils.send10EventsTo(loggerA);
- JulTestUtils.send10EventsTo(loggerB);
-
- assertTrue(session.stop());
-
- List<String> output = session.view();
- assertNotNull(output);
- assertEquals(10, output.size());
-
- ILttngHandler handler = getAgentHandler();
- assertEquals(10, handler.getEventCount());
- }
-
- /**
- * Get the singleton JUL Handler currently managed by the LTTngAgent. It is
- * not public, so we need reflection to access it.
- *
- * @return The agent's JUL handler
- */
- private static ILttngHandler getAgentHandler() {
- try {
- Field julHandlerField = LTTngAgent.class.getDeclaredField("julHandler");
- julHandlerField.setAccessible(true);
- return (ILttngHandler) julHandlerField.get(LTTngAgent.getLTTngAgent());
- } catch (ReflectiveOperationException | SecurityException e) {
- fail();
- return null;
- }
- }
-
-}
-
+++ /dev/null
-package org.lttng.ust.agent.integration.jul;
-
-import static org.junit.Assume.assumeTrue;
-
-import java.io.IOException;
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.lttng.ust.agent.integration.common.MultiSessionTest;
-import org.lttng.ust.agent.jul.LttngLogHandler;
-import org.lttng.ust.agent.utils.LttngSession;
-import org.lttng.ust.agent.utils.LttngSession.Domain;
-import org.lttng.ust.agent.utils.TestUtils;
-
-public class JulMultiSessionTest extends MultiSessionTest {
-
- private static final Domain DOMAIN = Domain.JUL;
-
- private Logger loggerA;
- private Logger loggerB;
- private Logger loggerC;
- private Logger loggerD;
-
- @BeforeClass
- public static void julClassSetup() {
- /* Skip tests if we can't find the JNI library or lttng-tools */
- assumeTrue(TestUtils.checkForJulLibrary());
- assumeTrue(TestUtils.checkForLttngTools(Domain.JUL));
-
- LttngSession.destroyAllSessions();
- }
-
- @AfterClass
- public static void julClassCleanup() {
- LttngSession.deleteAllTracee();
- }
-
- @Before
- public void julSetup() throws SecurityException, IOException {
- loggerA = Logger.getLogger(EVENT_NAME_A);
- loggerB = Logger.getLogger(EVENT_NAME_B);
- loggerC = Logger.getLogger(EVENT_NAME_C);
- loggerD = Logger.getLogger(EVENT_NAME_D);
-
- loggerA.setLevel(Level.ALL);
- loggerB.setLevel(Level.ALL);
- loggerC.setLevel(Level.ALL);
- loggerD.setLevel(Level.ALL);
-
- handlerA = new LttngLogHandler();
- handlerB = new LttngLogHandler();
- handlerC = new LttngLogHandler();
- handlerD = new LttngLogHandler();
-
- loggerA.addHandler((Handler) handlerA);
- loggerB.addHandler((Handler) handlerB);
- loggerC.addHandler((Handler) handlerC);
- loggerD.addHandler((Handler) handlerD);
- }
-
- @After
- public void julTeardown() {
- loggerA.removeHandler((Handler) handlerA);
- loggerB.removeHandler((Handler) handlerB);
- loggerC.removeHandler((Handler) handlerC);
- loggerD.removeHandler((Handler) handlerD);
-
- loggerA = null;
- loggerB = null;
- loggerC = null;
- loggerD = null;
- }
-
- @Override
- protected Domain getDomain() {
- return DOMAIN;
- }
-
- @Override
- protected void sendEventsToLoggers() {
- JulTestUtils.send10EventsTo(loggerA);
- JulTestUtils.send10EventsTo(loggerB);
- JulTestUtils.send10EventsTo(loggerC);
- JulTestUtils.send10EventsTo(loggerD);
- }
-}
+++ /dev/null
-package org.lttng.ust.agent.integration.jul;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-final class JulTestUtils {
-
- JulTestUtils() {
- }
-
- static void send10EventsTo(Logger logger) {
- String a = new String("a");
- Object[] params = { a, new String("b"), new Object() };
-
- // Levels are FINE, FINER, FINEST, INFO, SEVERE, WARNING
- logger.fine("A fine level message");
- logger.finer("A finer level message");
- logger.finest("A finest level message");
- logger.info("A info level message");
- logger.severe("A severe level message");
- logger.warning("A warning level message");
- logger.warning("Another warning level message");
- logger.log(Level.WARNING, "A warning message using Logger.log()");
- logger.log(Level.INFO, "A message with one parameter", a);
- logger.log(Level.INFO, "A message with parameters", params);
- }
-}
+++ /dev/null
-package org.lttng.ust.agent.integration.log4j;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- Log4jEnabledEventsTest.class,
- Log4jLegacyApiTest.class,
- Log4jMultiSessionTest.class
-})
-public class AllTests {
-
-}
+++ /dev/null
-package org.lttng.ust.agent.integration.log4j;
-
-import static org.junit.Assume.assumeTrue;
-
-import java.io.IOException;
-
-import org.apache.log4j.Appender;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.lttng.ust.agent.integration.common.EnabledEventsTest;
-import org.lttng.ust.agent.log4j.LttngLogAppender;
-import org.lttng.ust.agent.utils.LttngSession;
-import org.lttng.ust.agent.utils.LttngSession.Domain;
-import org.lttng.ust.agent.utils.TestUtils;
-
-public class Log4jEnabledEventsTest extends EnabledEventsTest {
-
- private static final Domain DOMAIN = Domain.LOG4J;
-
- private Logger loggerA;
- private Logger loggerB;
- private Logger loggerC;
- private Logger loggerD;
-
- @BeforeClass
- public static void log4jClassSetup() {
- /* Skip tests if we can't find the JNI library or lttng-tools */
- assumeTrue(TestUtils.checkForLog4jLibrary());
- assumeTrue(TestUtils.checkForLttngTools(Domain.LOG4J));
-
- LttngSession.destroyAllSessions();
- }
-
- @AfterClass
- public static void log4jClassCleanup() {
- LttngSession.deleteAllTracee();
- }
-
- @Before
- public void log4jSetup() throws SecurityException, IOException {
- loggerA = Logger.getLogger(EVENT_NAME_A);
- loggerB = Logger.getLogger(EVENT_NAME_B);
- loggerC = Logger.getLogger(EVENT_NAME_C);
- loggerD = Logger.getLogger(EVENT_NAME_D);
-
- loggerA.setLevel(Level.ALL);
- loggerB.setLevel(Level.ALL);
- loggerC.setLevel(Level.ALL);
- loggerD.setLevel(Level.ALL);
-
- handlerA = new LttngLogAppender();
- handlerB = new LttngLogAppender();
- handlerC = new LttngLogAppender();
-
- loggerA.addAppender((Appender) handlerA);
- loggerB.addAppender((Appender) handlerB);
- loggerC.addAppender((Appender) handlerC);
- }
-
- @After
- public void log4jTeardown() {
- loggerA.removeAppender((Appender) handlerA);
- loggerB.removeAppender((Appender) handlerB);
- loggerC.removeAppender((Appender) handlerC);
-
- loggerA = null;
- loggerB = null;
- loggerC = null;
- loggerD = null;
- }
-
- @Override
- protected Domain getDomain() {
- return DOMAIN;
- }
-
- @Override
- protected void sendEventsToLoggers() {
- Log4jTestUtils.send10Events(loggerA);
- Log4jTestUtils.send10Events(loggerB);
- Log4jTestUtils.send10Events(loggerC);
- Log4jTestUtils.send10Events(loggerD);
- }
-}
+++ /dev/null
-package org.lttng.ust.agent.integration.log4j;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.junit.Assume.assumeTrue;
-
-import java.lang.reflect.Field;
-import java.util.List;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.lttng.ust.agent.ILttngHandler;
-import org.lttng.ust.agent.LTTngAgent;
-import org.lttng.ust.agent.utils.LttngSession;
-import org.lttng.ust.agent.utils.LttngSession.Domain;
-import org.lttng.ust.agent.utils.TestUtils;
-
-@SuppressWarnings("deprecation")
-public class Log4jLegacyApiTest {
-
- private static final Domain DOMAIN = Domain.LOG4J;
-
- private static final String EVENT_NAME_A = "EventA";
- private static final String EVENT_NAME_B = "EventB";
-
- private LttngSession session;
-
- private Logger loggerA;
- private Logger loggerB;
-
- @BeforeClass
- public static void classSetup() {
- /* Skip tests if we can't find the JNI library or lttng-tools */
- assumeTrue(TestUtils.checkForLog4jLibrary());
- assumeTrue(TestUtils.checkForLttngTools(Domain.LOG4J));
-
- LttngSession.destroyAllSessions();
- }
-
- @AfterClass
- public static void classCleanup() {
- LttngSession.deleteAllTracee();
- }
-
- @Before
- public void setup() {
- loggerA = Logger.getLogger(EVENT_NAME_A);
- LTTngAgent.getLTTngAgent();
- loggerB = Logger.getLogger(EVENT_NAME_B);
-
- loggerA.setLevel(Level.ALL);
- loggerB.setLevel(Level.ALL);
-
- session = new LttngSession(null, DOMAIN);
- }
-
- @After
- public void tearDown() {
- session.close();
-
- LTTngAgent.dispose();
-
- loggerA = null;
- loggerB = null;
- }
-
- @Test
- public void testNoEvents() {
- assertTrue(session.start());
-
- Log4jTestUtils.send10Events(loggerA);
- Log4jTestUtils.send10Events(loggerB);
-
- assertTrue(session.stop());
-
- List<String> output = session.view();
- assertNotNull(output);
- assertTrue(output.isEmpty());
-
- ILttngHandler handler = getAgentHandler();
- assertEquals(0, handler.getEventCount());
- }
-
- @Test
- public void testAllEvents() {
- assertTrue(session.enableAllEvents());
- assertTrue(session.start());
-
- Log4jTestUtils.send10Events(loggerA);
- Log4jTestUtils.send10Events(loggerB);
-
- assertTrue(session.stop());
-
- List<String> output = session.view();
- assertNotNull(output);
- assertEquals(20, output.size());
-
- ILttngHandler handler = getAgentHandler();
- assertEquals(20, handler.getEventCount());
- }
-
- @Test
- public void testSomeEvents() {
- assertTrue(session.enableEvents(EVENT_NAME_A));
- assertTrue(session.start());
-
- Log4jTestUtils.send10Events(loggerA);
- Log4jTestUtils.send10Events(loggerB);
-
- assertTrue(session.stop());
-
- List<String> output = session.view();
- assertNotNull(output);
- assertEquals(10, output.size());
-
- ILttngHandler handler = getAgentHandler();
- assertEquals(10, handler.getEventCount());
- }
-
- /**
- * Get the singleton Log4j Handler currently managed by the LTTngAgent. It
- * is not public, so we need reflection to access it.
- *
- * @return The agent's Log4j handler
- */
- private static ILttngHandler getAgentHandler() {
- try {
- Field log4jAppenderField = LTTngAgent.class.getDeclaredField("log4jAppender");
- log4jAppenderField.setAccessible(true);
- return (ILttngHandler) log4jAppenderField.get(LTTngAgent.getLTTngAgent());
- } catch (ReflectiveOperationException | SecurityException e) {
- fail();
- return null;
- }
- }
-
-}
-
+++ /dev/null
-package org.lttng.ust.agent.integration.log4j;
-
-import static org.junit.Assume.assumeTrue;
-
-import java.io.IOException;
-
-import org.apache.log4j.Appender;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.lttng.ust.agent.integration.common.MultiSessionTest;
-import org.lttng.ust.agent.log4j.LttngLogAppender;
-import org.lttng.ust.agent.utils.LttngSession;
-import org.lttng.ust.agent.utils.LttngSession.Domain;
-import org.lttng.ust.agent.utils.TestUtils;
-
-public class Log4jMultiSessionTest extends MultiSessionTest {
-
- private static final Domain DOMAIN = Domain.LOG4J;
-
- private Logger loggerA;
- private Logger loggerB;
- private Logger loggerC;
- private Logger loggerD;
-
- @BeforeClass
- public static void log4jClassSetup() {
- /* Skip tests if we can't find the JNI library or lttng-tools */
- assumeTrue(TestUtils.checkForLog4jLibrary());
- assumeTrue(TestUtils.checkForLttngTools(Domain.LOG4J));
-
- LttngSession.destroyAllSessions();
- }
-
- @AfterClass
- public static void log4jClassCleanup() {
- LttngSession.deleteAllTracee();
- }
-
- @Before
- public void log4jSetup() throws SecurityException, IOException {
- // TODO Wipe all existing LTTng sessions?
-
- loggerA = Logger.getLogger(EVENT_NAME_A);
- loggerB = Logger.getLogger(EVENT_NAME_B);
- loggerC = Logger.getLogger(EVENT_NAME_C);
- loggerD = Logger.getLogger(EVENT_NAME_D);
-
- loggerA.setLevel(Level.ALL);
- loggerB.setLevel(Level.ALL);
- loggerC.setLevel(Level.ALL);
- loggerD.setLevel(Level.ALL);
-
- handlerA = new LttngLogAppender();
- handlerB = new LttngLogAppender();
- handlerC = new LttngLogAppender();
- handlerD = new LttngLogAppender();
-
- loggerA.addAppender((Appender) handlerA);
- loggerB.addAppender((Appender) handlerB);
- loggerC.addAppender((Appender) handlerC);
- loggerD.addAppender((Appender) handlerD);
- }
-
- @After
- public void log4jTeardown() {
- loggerA.removeAppender((Appender) handlerA);
- loggerB.removeAppender((Appender) handlerB);
- loggerC.removeAppender((Appender) handlerC);
- loggerD.removeAppender((Appender) handlerD);
-
- loggerA = null;
- loggerB = null;
- loggerC = null;
- loggerD = null;
- }
-
- @Override
- protected Domain getDomain() {
- return DOMAIN;
- }
-
- @Override
- protected void sendEventsToLoggers() {
- Log4jTestUtils.send10Events(loggerA);
- Log4jTestUtils.send10Events(loggerB);
- Log4jTestUtils.send10Events(loggerC);
- Log4jTestUtils.send10Events(loggerD);
- }
-}
+++ /dev/null
-package org.lttng.ust.agent.integration.log4j;
-
-import java.io.IOException;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-
-final class Log4jTestUtils {
-
- private Log4jTestUtils() {
- }
-
- static void send10Events(Logger logger) {
- // Levels/priorities are DEBUG, ERROR, FATAL, INFO, TRACE, WARN
- logger.debug("Debug message. Lost among so many.");
- logger.debug("Debug message with a throwable", new IOException());
- logger.error("Error messsage. This might be bad.");
- logger.error("Error message with a throwable", new IOException());
- logger.fatal("A fatal message. You are already dead.");
- logger.info("A info message. Lol, who cares.");
- logger.trace("A trace message. No, no *that* trace");
- logger.warn("A warn message. Yellow underline.");
- logger.log(Level.DEBUG, "A debug message using .log()");
- logger.log(Level.ERROR, "A error message using .log()");
- }
-}
+++ /dev/null
-package org.lttng.ust.agent.utils;
-
-import java.io.IOException;
-import java.lang.ProcessBuilder.Redirect;
-import java.nio.file.FileVisitResult;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.Arrays;
-import java.util.List;
-import java.util.UUID;
-import java.util.stream.Collectors;
-
-public class LttngSession implements AutoCloseable {
-
- public enum Domain {
- JUL("-j"),
- LOG4J("-l");
-
- private final String flag;
-
- private Domain(String flag) {
- this.flag = flag;
- }
-
- public String flag() {
- return flag;
- }
- }
-
- private final String sessionName;
- private final Domain domain;
-
- private volatile boolean channelCreated = false;
-
- public LttngSession(String sessionName, Domain domain) {
- if (sessionName != null) {
- this.sessionName = sessionName;
- } else {
- this.sessionName = UUID.randomUUID().toString();
- }
- this.domain = domain;
-
- /* Create the session in LTTng */
- executeCommand(Arrays.asList("lttng", "create", this.sessionName));
- }
-
- @Override
- public void close() {
- /* Destroy the session */
- executeCommand(Arrays.asList("lttng", "destroy", sessionName));
- // FIXME also delete the trace we generated ?
- }
-
- // ------------------------------------------------------------------------
- // Public methods
- // ------------------------------------------------------------------------
-
- /**
- * Enable all events in the given session (enable-event -a)
- *
- * @return If the command executed successfully (return code = 0).
- */
- public boolean enableAllEvents() {
- channelCreated = true;
- return executeCommand(Arrays.asList(
- "lttng", "enable-event", domain.flag(), "-a", "-s", sessionName));
- }
-
- /**
- * Enable individual event(s).
- *
- * @param enabledEvents
- * The list of events to enable. Should not be null or empty
- * @return If the command executed successfully (return code = 0).
- */
- public boolean enableEvents(String... enabledEvents) {
- if (enabledEvents == null || enabledEvents.length == 0) {
- throw new IllegalArgumentException();
- }
- channelCreated = true;
- return executeCommand(Arrays.asList(
- "lttng", "enable-event", domain.flag(),
- Arrays.stream(enabledEvents).collect(Collectors.joining(",")),
- "-s", sessionName));
- }
-
- /**
- * Send a disable-event command. Used to disable events that were previously
- * enabled.
- *
- * @param disabledEvents
- * The list of disabled events. Should not be null or empty
- * @return If the command executed successfully (return code = 0).
- */
- public boolean disableEvents(String... disabledEvents) {
- if (disabledEvents == null || disabledEvents.length == 0) {
- throw new IllegalArgumentException();
- }
- return executeCommand(Arrays.asList(
- "lttng", "disable-event", domain.flag(),
- Arrays.stream(disabledEvents).collect(Collectors.joining(",")),
- "-s", sessionName));
- }
-
- public boolean start() {
- /*
- * We have to enable a channel for 'lttng start' to work. However, we
- * cannot enable a channel directly, see
- * https://bugs.lttng.org/issues/894 . Instead we will enable an event
- * we know does not exist
- */
- if (!channelCreated) {
- enableEvents("non-event");
- }
- return executeCommand(Arrays.asList("lttng", "start", sessionName));
- }
-
- /**
- * Stop the tracing session
- *
- * @return If the command executed successfully (return code = 0).
- */
- public boolean stop() {
- return executeCommand(Arrays.asList("lttng", "stop", sessionName));
- }
-
- /**
- * Issue a "lttng view" command on the session, and returns its output. This
- * effectively returns the current content of the trace in text form.
- *
- * @return The output of Babeltrace on the session's current trace
- */
- public List<String> view() {
- return TestUtils.getOutputFromCommand(Arrays.asList("lttng", "view", sessionName));
- }
-
- /**
- * Utility method to destroy all existing sessions. Useful when first
- * setting up a test to make sure no existing session interferes.
- */
- public static void destroyAllSessions() {
- executeCommand(Arrays.asList("lttng", "destroy", "-a"));
- }
-
- /**
- * Outside of the scope of lttng-tools, but this utility method can be used
- * to delete all traces currently under ~/lttng-traces/. This can be used by
- * tests to cleanup a trace they have created.
- *
- * @return True if the command completes successfully, false if there was an
- * error.
- */
- public static boolean deleteAllTracee() {
- String tracesDir = new String(System.getProperty("user.home") + "/lttng-traces/");
- return deleteDirectory(Paths.get(tracesDir));
- }
-
- // ------------------------------------------------------------------------
- // Private helper methods
- // ------------------------------------------------------------------------
-
- private static boolean deleteDirectory(Path directory) {
- try {
- Files.walkFileTree(directory, new SimpleFileVisitor<Path>() {
- @Override
- public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
- Files.delete(file);
- return FileVisitResult.CONTINUE;
- }
-
- @Override
- public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
- Files.delete(dir);
- return FileVisitResult.CONTINUE;
- }
- });
- } catch (IOException e) {
- /* At least we tried... */
- return false;
- }
- return true;
- }
-
- /**
- * Just to test the environment / stdout are working correctly
- */
- public static void main(String[] args) {
- List<String> command = Arrays.asList("ls", "-l");
- executeCommand(command);
- }
-
- private static boolean executeCommand(List<String> command) {
- try {
- ProcessBuilder builder = new ProcessBuilder(command);
- builder.redirectErrorStream(true);
- builder.redirectOutput(Redirect.INHERIT);
-
- Process p = builder.start();
- int ret = p.waitFor();
- return (ret == 0);
-
- } catch (IOException | InterruptedException e) {
- return false;
- }
- }
-}
+++ /dev/null
-package org.lttng.ust.agent.utils;
-
-import java.io.IOException;
-import java.lang.ProcessBuilder.Redirect;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Arrays;
-import java.util.List;
-
-import org.lttng.ust.agent.jul.LttngLogHandler;
-import org.lttng.ust.agent.log4j.LttngLogAppender;
-import org.lttng.ust.agent.utils.LttngSession.Domain;
-
-/**
- * Utility methods to help with UST-Java tests
- */
-public final class TestUtils {
-
- private TestUtils() {}
-
- /**
- * Check the the JUL native library is available, effectively allowing LTTng
- * JUL handlers to be used.
- *
- * @return True if JUL works fine, false if it does not.
- */
- public static boolean checkForJulLibrary() {
- try {
- LttngLogHandler testHandler = new LttngLogHandler();
- testHandler.close();
- } catch (SecurityException | IOException e) {
- return false;
- }
- return true;
- }
-
- /**
- * Check the the Log4j native library is available, effectively allowing
- * LTTng Log4j appenders to be used.
- *
- * @return True if Log4j works fine, false if it does not.
- */
- public static boolean checkForLog4jLibrary() {
- try {
- LttngLogAppender testAppender = new LttngLogAppender();
- testAppender.close();
- } catch (SecurityException | IOException e) {
- return false;
- }
- return true;
- }
-
- /**
- * Check that lttng-tools and babeltrace are installed on the system and
- * working.
- *
- * @param domain
- * The tracing domain to test for (we will try to setup a session
- * with this domain)
- * @return True if the environment should allow tracing fine, false if there
- * was an error
- */
- public static boolean checkForLttngTools(Domain domain) {
- try (LttngSession session = new LttngSession(null, domain)) {
- boolean ret1 = session.enableAllEvents();
- boolean ret2 = session.start();
- boolean ret3 = session.stop();
- /*
- * "lttng view" also tests that Babeltrace is installed and working
- */
- List<String> contents = session.view();
- return (ret1 && ret2 && ret3 && contents.isEmpty());
- }
- }
-
- public static boolean checkForUserSessiond() {
- String userName = System.getProperty("user.name");
-
- /* The user name is truncated to 7 characters in "ps" */
- String shortUserName = userName.substring(0, Math.min(userName.length(), 7));
-
- List<String> command = Arrays.asList("ps", "-e", "u");
- List<String> output = getOutputFromCommand(false, command);
- return output.stream()
- .filter(s -> s.contains("lttng-sessiond"))
- .anyMatch(s -> s.startsWith(shortUserName));
- }
-
- public static boolean checkForRootSessiond() {
- List<String> command = Arrays.asList("ps", "-e", "u");
- List<String> output = getOutputFromCommand(false, command);
- return output.stream()
- .filter(s -> s.contains("lttng-sessiond"))
- .anyMatch(s -> s.startsWith("root"));
- }
-
-
- static List<String> getOutputFromCommand(List<String> command) {
- return TestUtils.getOutputFromCommand(true, command);
- }
-
- static List<String> getOutputFromCommand(boolean print, List<String> command) {
- try {
- Path tempFile = Files.createTempFile("test-output", null);
-
- ProcessBuilder builder = new ProcessBuilder(command);
- builder.redirectErrorStream(true);
- builder.redirectOutput(Redirect.to(tempFile.toFile()));
-
- Process p = builder.start();
- p.waitFor();
-
- List<String> lines = Files.readAllLines(tempFile);
- Files.delete(tempFile);
-
- if (print) {
- /* Also print the output to the console */
- lines.stream().forEach(s -> System.out.println(s));
- }
-
- return lines;
-
- } catch (IOException | InterruptedException e) {
- return null;
- }
- }
-}
--- /dev/null
+package org.lttng.ust.agent.benchmarks.jul.handler;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public abstract class AbstractJulBenchmark {
+
+ // ------------------------------------------------------------------------
+ // Configurable test parameters
+ // ------------------------------------------------------------------------
+
+ /** Nb of runs per test, result will be averaged */
+ private static final int NB_RUNS = 10;
+
+ /** Trace/log events per run */
+ private static final int NB_ITER = 100000;
+
+ /** Which tests to run (for different number of threads) */
+ private static final int[] NB_THREADS = {1, 1, 2, 3, 4, 5, 6, 7, 8};
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ protected Logger logger;
+ protected Handler handler;
+
+ // ------------------------------------------------------------------------
+ // Maintenance methods
+ // ------------------------------------------------------------------------
+
+ @Before
+ public void setup() {
+ /* Set up the logger */
+ logger = Logger.getLogger("Test logger");
+ logger.setUseParentHandlers(false);
+ logger.setLevel(Level.ALL);
+
+ /* Sub-classes' @Before will setup the Handler */
+ }
+
+ @After
+ public void teardown() {
+ if (handler != null) {
+ logger.removeHandler(handler);
+ handler.close();
+ }
+ handler = null;
+ logger = null;
+ }
+
+ // ------------------------------------------------------------------------
+ // Test methods
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void runBenchmark() {
+ if (handler != null) {
+ logger.addHandler(handler);
+ }
+
+ System.out.println();
+ System.out.println("Running benchmark: " + this.getClass().getCanonicalName());
+ for (int i : NB_THREADS) {
+ runTest(logger, i);
+ }
+ }
+
+ private static void runTest(Logger log, int nbThreads) {
+ long start, end, average, total = 0;
+ for (int i = 0; i < NB_RUNS; i++) {
+ Runner runner = new Runner(nbThreads, NB_ITER, log);
+
+ start = System.nanoTime();
+ runner.run();
+ end = System.nanoTime();
+
+ total += (end - start);
+ }
+ average = total / NB_RUNS;
+ System.out.println(nbThreads + " threads, average = " + average / NB_ITER + " ns/event");
+ }
+
+ // ------------------------------------------------------------------------
+ // Helper classes
+ // ------------------------------------------------------------------------
+
+ private static class Runner implements Runnable {
+
+ private final List<Worker> workers = new LinkedList<>();
+ private final List<Thread> workerThreads = new LinkedList<>();
+
+ public Runner(int nbThreads, int nbIter, Logger log) {
+
+ for (int id = 0; id < nbThreads; id++) {
+ Worker curWorker = new Worker(id, nbIter, log);
+ workers.add(curWorker);
+ workerThreads.add(new Thread(curWorker, "worker " + id));
+ }
+ }
+
+ @Override
+ public void run() {
+ for (Thread curThread : workerThreads) {
+ curThread.start();
+ }
+
+ for (Thread curThread : workerThreads) {
+ try {
+ curThread.join();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private static class Worker implements Runnable {
+
+ private final Logger log;
+ private final int threadId;
+ private final int nbIter;
+
+ public Worker(int threadId, int nbIter, Logger log) {
+ this.log = log;
+ this.threadId = threadId;
+ this.nbIter = nbIter;
+ }
+
+ @Override
+ public void run() {
+ for (int i = 0; i < nbIter; i++) {
+ log.info("Thread " + threadId + ", iteration " + i);
+ }
+ }
+
+ }
+ }
+}
--- /dev/null
+package org.lttng.ust.agent.benchmarks.jul.handler;
+
+import java.util.logging.Handler;
+import java.util.logging.LogRecord;
+
+import org.junit.Before;
+
+public class DummyHandlerBenchmark extends AbstractJulBenchmark {
+
+ @Before
+ public void testSetup() {
+ handler = new DummyHandler();
+ }
+
+ private static class DummyHandler extends Handler {
+
+ public DummyHandler() {
+ super();
+ }
+
+ @Override
+ public void close() throws SecurityException {}
+
+ @Override
+ public void flush() {}
+
+ @Override
+ public void publish(LogRecord record) {}
+
+ }
+}
--- /dev/null
+package org.lttng.ust.agent.benchmarks.jul.handler;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.logging.FileHandler;
+import java.util.logging.SimpleFormatter;
+
+import org.junit.After;
+import org.junit.Before;
+
+public class FileHandlerBenchmark extends AbstractJulBenchmark {
+
+ private Path outputFile;
+
+ @Before
+ public void testSetup() throws SecurityException, IOException {
+ outputFile = Files.createTempFile(this.getClass().getSimpleName(), null);
+
+ handler = new FileHandler(outputFile.toString(), false);
+ handler.setFormatter(new SimpleFormatter());
+ }
+
+ @After
+ public void testTeardown() throws IOException {
+ Files.deleteIfExists(outputFile);
+ }
+}
--- /dev/null
+package org.lttng.ust.agent.benchmarks.jul.handler;
+
+public class NoHandlerBenchmark extends AbstractJulBenchmark {
+
+ /* Do not setup any handler */
+}
--- /dev/null
+package org.lttng.ust.agent.benchmarks.jul.handler.lttng;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+
+import org.junit.After;
+import org.junit.Before;
+import org.lttng.ust.agent.benchmarks.jul.handler.AbstractJulBenchmark;
+import org.lttng.ust.agent.jul.LttngLogHandler;
+import org.lttng.ust.agent.utils.LttngSession;
+import org.lttng.ust.agent.utils.LttngSession.Domain;
+
+public class LttngJulHandlerTracingDisabledBenchmark extends AbstractJulBenchmark {
+
+ private LttngSession session;
+
+ @Before
+ public void testSetup() throws IOException {
+ handler = new LttngLogHandler();
+
+ session = new LttngSession(null, Domain.JUL);
+ assertTrue(session.enableEvents("non-event"));
+ assertTrue(session.start());
+ }
+
+ @After
+ public void testTeardown() {
+ assertTrue(session.stop());
+ session.close();
+ }
+}
--- /dev/null
+package org.lttng.ust.agent.benchmarks.jul.handler.lttng;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+
+import org.junit.After;
+import org.junit.Before;
+import org.lttng.ust.agent.benchmarks.jul.handler.AbstractJulBenchmark;
+import org.lttng.ust.agent.jul.LttngLogHandler;
+import org.lttng.ust.agent.utils.LttngSession;
+import org.lttng.ust.agent.utils.LttngSession.Domain;
+
+public class LttngJulHandlerTracingEnabledBenchmark extends AbstractJulBenchmark {
+
+ private LttngSession session;
+
+ @Before
+ public void testSetup() throws IOException {
+ handler = new LttngLogHandler();
+
+ session = new LttngSession(null, Domain.JUL);
+ assertTrue(session.enableAllEvents());
+ assertTrue(session.start());
+ }
+
+ @After
+ public void testTeardown() {
+ assertTrue(session.stop());
+ session.close();
+ }
+}
--- /dev/null
+package org.lttng.ust.agent.benchmarks.jul.handler.lttng.old;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.After;
+import org.junit.Before;
+import org.lttng.ust.agent.LTTngAgent;
+import org.lttng.ust.agent.benchmarks.jul.handler.AbstractJulBenchmark;
+import org.lttng.ust.agent.utils.LttngSession;
+import org.lttng.ust.agent.utils.LttngSession.Domain;
+
+@SuppressWarnings("deprecation")
+public class OldLttngJulHandlerTracingDisabledBenchmark extends AbstractJulBenchmark {
+
+ private LttngSession session;
+
+ @Before
+ public void testSetup() {
+ LTTngAgent.getLTTngAgent();
+
+ session = new LttngSession(null, Domain.JUL);
+ assertTrue(session.enableEvents("non-event"));
+ assertTrue(session.start());
+ }
+
+ @After
+ public void testTeardown() {
+ assertTrue(session.stop());
+ session.close();
+
+ LTTngAgent.dispose();
+ }
+}
--- /dev/null
+package org.lttng.ust.agent.benchmarks.jul.handler.lttng.old;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Field;
+
+import org.junit.After;
+import org.junit.Before;
+import org.lttng.ust.agent.LTTngAgent;
+import org.lttng.ust.agent.benchmarks.jul.handler.AbstractJulBenchmark;
+import org.lttng.ust.agent.jul.LttngLogHandler;
+import org.lttng.ust.agent.utils.LttngSession;
+import org.lttng.ust.agent.utils.LttngSession.Domain;
+
+@SuppressWarnings("deprecation")
+public class OldLttngJulHandlerTracingEnabledBenchmark extends AbstractJulBenchmark {
+
+ private LttngSession session;
+ private LttngLogHandler agentHandler;
+
+ @Before
+ public void testSetup() {
+ LTTngAgent agentInstance = LTTngAgent.getLTTngAgent();
+
+ /*
+ * The "old API" works by attaching a handler managed by the agent to
+ * the root JUL logger. This causes problems here, because we use
+ * logger.setUserParentHandler(false), which does not trigger the
+ * handler as would be expected.
+ *
+ * Instead we will retrieve this handler through reflection, and attach
+ * it to our own logger here for the duration of the test.
+ */
+ try {
+ Field julHandlerField = LTTngAgent.class.getDeclaredField("julHandler");
+ julHandlerField.setAccessible(true);
+ agentHandler = (LttngLogHandler) julHandlerField.get(agentInstance);
+
+ logger.addHandler(agentHandler);
+
+ } catch (ReflectiveOperationException e) {
+ fail();
+ }
+
+ session = new LttngSession(null, Domain.JUL);
+ assertTrue(session.enableAllEvents());
+ assertTrue(session.start());
+ }
+
+ @After
+ public void testTeardown() {
+ assertTrue(session.stop());
+ session.close();
+
+ logger.removeHandler(agentHandler);
+ LTTngAgent.dispose();
+ }
+}
--- /dev/null
+package org.lttng.ust.agent.integration;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.lttng.ust.agent.ILttngHandler;
+import org.lttng.ust.agent.utils.LttngSession;
+import org.lttng.ust.agent.utils.LttngSession.Domain;
+
+public abstract class EnabledEventsTestBase {
+
+ protected static final String EVENT_NAME_A = "EventA";
+ protected static final String EVENT_NAME_B = "EventAB";
+ protected static final String EVENT_NAME_C = "EventABC";
+ protected static final String EVENT_NAME_D = "EventABCD";
+
+ private LttngSession session;
+
+ /* Fields defined by the sub-class */
+ protected ILttngHandler handlerA;
+ protected ILttngHandler handlerB;
+ protected ILttngHandler handlerC;
+
+ protected abstract Domain getDomain();
+
+ protected abstract void sendEventsToLoggers();
+
+ @Before
+ public void testSetup() {
+ session = new LttngSession(null, getDomain());
+ }
+
+ @After
+ public void testTeardown() {
+ session.close();
+
+ handlerA.close();
+ handlerB.close();
+ handlerC.close();
+
+ handlerA = null;
+ handlerB = null;
+ handlerC = null;
+ }
+
+ /**
+ * Test sending events on the Java side, but no events enabled in the
+ * tracing session. There should be nothing in the resulting trace, and
+ * handlers should not have logged anything.
+ */
+ @Test
+ public void testNoEvents() {
+ assertTrue(session.start());
+
+ sendEventsToLoggers();
+
+ assertTrue(session.stop());
+
+ List<String> output = session.view();
+ assertNotNull(output);
+ assertTrue(output.isEmpty());
+
+ assertEquals(0, handlerA.getEventCount());
+ assertEquals(0, handlerB.getEventCount());
+ assertEquals(0, handlerC.getEventCount());
+ }
+
+ /**
+ * Test sending events on the Java side, and all events enabled in the
+ * tracing session. All handlers should have sent their events.
+ */
+ @Test
+ public void testAllEvents() {
+ assertTrue(session.enableAllEvents());
+ assertTrue(session.start());
+
+ sendEventsToLoggers();
+
+ assertTrue(session.stop());
+
+ List<String> output = session.view();
+ assertNotNull(output);
+ assertEquals(30, output.size()); // loggerD has no handler attached
+
+ assertEquals(10, handlerA.getEventCount());
+ assertEquals(10, handlerB.getEventCount());
+ assertEquals(10, handlerC.getEventCount());
+ }
+
+ /**
+ * Test sending events on the Java side, with only some of them enabled in
+ * the tracing session. Only the subset that is enabled should be received.
+ */
+ @Test
+ public void testSomeEvents() {
+ assertTrue(session.enableEvents(EVENT_NAME_A, EVENT_NAME_C, EVENT_NAME_D));
+ assertTrue(session.start());
+
+ sendEventsToLoggers();
+
+ assertTrue(session.stop());
+
+ List<String> output = session.view();
+ assertNotNull(output);
+ assertEquals(20, output.size());
+
+ assertEquals(10, handlerA.getEventCount());
+ assertEquals(0, handlerB.getEventCount());
+ assertEquals(10, handlerC.getEventCount());
+ }
+
+ /**
+ * Test with all events enabled (-a), plus some other events added manually.
+ * Events should still be retained, but there should be no duplicates.
+ */
+ @Test
+ public void testAllEventsAndSome() {
+ assertTrue(session.enableAllEvents());
+ assertTrue(session.enableEvents(EVENT_NAME_A, EVENT_NAME_B));
+ assertTrue(session.start());
+
+ sendEventsToLoggers();
+
+ assertTrue(session.stop());
+
+ List<String> output = session.view();
+ assertNotNull(output);
+ assertEquals(30, output.size());
+
+ assertEquals(10, handlerA.getEventCount());
+ assertEquals(10, handlerB.getEventCount());
+ assertEquals(10, handlerC.getEventCount());
+ }
+
+ /**
+ * Same as {@link #testSomeEvents()}, but some events were enabled first,
+ * then disabled. Makes sure the enabled-event refcounting works properly.
+ */
+ @Test
+ public void testSomeEventsAfterDisabling() {
+ assertTrue(session.enableEvents(EVENT_NAME_A, EVENT_NAME_C, EVENT_NAME_D));
+ assertTrue(session.disableEvents(EVENT_NAME_C));
+ assertTrue(session.start());
+
+ sendEventsToLoggers();
+
+ assertTrue(session.stop());
+
+ List<String> output = session.view();
+ assertNotNull(output);
+ assertEquals(10, output.size());
+
+ assertEquals(10, handlerA.getEventCount());
+ assertEquals(0, handlerB.getEventCount());
+ assertEquals(0, handlerC.getEventCount());
+ }
+
+ /**
+ * Test enabling an event prefix, which means an event name ending with a *,
+ * to match all events starting with this name.
+ */
+ @Test
+ public void testEventPrefix() {
+ // should match event/loggers B and C, but not A.
+ assertTrue(session.enableEvents("EventAB*"));
+ assertTrue(session.start());
+
+ sendEventsToLoggers();
+
+ assertTrue(session.stop());
+
+ List<String> output = session.view();
+ assertNotNull(output);
+ assertEquals(20, output.size());
+
+ assertEquals(0, handlerA.getEventCount());
+ assertEquals(10, handlerB.getEventCount());
+ assertEquals(10, handlerC.getEventCount());
+ }
+
+ /**
+ * Same as {@link #testEventPrefix()}, but with multiple prefixes that
+ * overlap. There should not be any duplicate events in the trace or in the
+ * handlers.
+ */
+ @Test
+ public void testEventPrefixOverlapping() {
+ // should still match B and C
+ assertTrue(session.enableEvents("EventAB*", "EventABC*"));
+ assertTrue(session.start());
+
+ sendEventsToLoggers();
+
+ assertTrue(session.stop());
+
+ List<String> output = session.view();
+ assertNotNull(output);
+ assertEquals(20, output.size());
+
+ assertEquals(0, handlerA.getEventCount());
+ assertEquals(10, handlerB.getEventCount());
+ assertEquals(10, handlerC.getEventCount());
+ }
+
+ /**
+ * Test with all events enabled (-a), plus an event prefix. Once again,
+ * there should be no duplicates.
+ */
+ @Test
+ public void testAllEventsAndPrefix() {
+ assertTrue(session.enableAllEvents());
+ assertTrue(session.enableEvents("EventAB*"));
+ assertTrue(session.start());
+
+ sendEventsToLoggers();
+
+ assertTrue(session.stop());
+
+ List<String> output = session.view();
+ assertNotNull(output);
+ assertEquals(30, output.size());
+
+ assertEquals(10, handlerA.getEventCount());
+ assertEquals(10, handlerB.getEventCount());
+ assertEquals(10, handlerC.getEventCount());
+ }
+}
--- /dev/null
+package org.lttng.ust.agent.integration;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.lttng.ust.agent.ILttngHandler;
+import org.lttng.ust.agent.utils.LttngSession;
+import org.lttng.ust.agent.utils.LttngSession.Domain;
+
+/**
+ * Tests with multiple concurrent tracing sessions
+ */
+public abstract class MultiSessionTestBase {
+
+ protected static final String EVENT_NAME_A = "EventA";
+ protected static final String EVENT_NAME_B = "EventAB";
+ protected static final String EVENT_NAME_C = "EventABC";
+ protected static final String EVENT_NAME_D = "EventABCD";
+
+ private LttngSession session1;
+ private LttngSession session2;
+ private LttngSession session3;
+
+ /* Fields defined by the sub-class */
+ protected ILttngHandler handlerA;
+ protected ILttngHandler handlerB;
+ protected ILttngHandler handlerC;
+ protected ILttngHandler handlerD;
+
+ protected abstract Domain getDomain();
+
+ protected abstract void sendEventsToLoggers();
+
+ @Before
+ public void testSetup() {
+ session1 = new LttngSession(null, getDomain());
+ session2 = new LttngSession(null, getDomain());
+ session3 = new LttngSession(null, getDomain());
+ }
+
+ @After
+ public void testTeardown() {
+ session1.close();
+ session2.close();
+ session3.close();
+
+ handlerA.close();
+ handlerB.close();
+ handlerC.close();
+ handlerD.close();
+
+ handlerA = null;
+ handlerB = null;
+ handlerC = null;
+ handlerD = null;
+ }
+
+ /**
+ * Test with no events in any session.
+ */
+ @Test
+ public void testNoEvents() {
+ assertTrue(session1.start());
+ assertTrue(session2.start());
+ assertTrue(session3.start());
+
+ sendEventsToLoggers();
+
+ assertTrue(session1.stop());
+ assertTrue(session2.stop());
+ assertTrue(session3.stop());
+
+ List<String> output1 = session1.view();
+ List<String> output2 = session2.view();
+ List<String> output3 = session3.view();
+ assertNotNull(output1);
+ assertNotNull(output2);
+ assertNotNull(output3);
+ assertTrue(output1.isEmpty());
+ assertTrue(output2.isEmpty());
+ assertTrue(output3.isEmpty());
+
+ assertEquals(0, handlerA.getEventCount());
+ assertEquals(0, handlerB.getEventCount());
+ assertEquals(0, handlerC.getEventCount());
+ assertEquals(0, handlerD.getEventCount());
+ }
+
+ /**
+ * Test with all events enabled in one session only. Everything should be
+ * sent through JNI, but only that session should keep the trace events.
+ */
+ @Test
+ public void testAllEventsOneSession() {
+ assertTrue(session1.enableAllEvents());
+ assertTrue(session1.start());
+ assertTrue(session2.start());
+ assertTrue(session3.start());
+
+ sendEventsToLoggers();
+
+ assertTrue(session1.stop());
+ assertTrue(session2.stop());
+ assertTrue(session3.stop());
+
+ List<String> output1 = session1.view();
+ List<String> output2 = session2.view();
+ List<String> output3 = session3.view();
+ assertNotNull(output1);
+ assertNotNull(output2);
+ assertNotNull(output3);
+ assertEquals(40, output1.size());
+ assertTrue(output2.isEmpty());
+ assertTrue(output3.isEmpty());
+
+ assertEquals(10, handlerA.getEventCount());
+ assertEquals(10, handlerB.getEventCount());
+ assertEquals(10, handlerC.getEventCount());
+ assertEquals(10, handlerD.getEventCount());
+ }
+
+ /**
+ * Test with all events enabled in all sessions. All traces and handlers
+ * should see every event that was logged.
+ */
+ @Test
+ public void testAllEventsAllSessions() {
+ assertTrue(session1.enableAllEvents());
+ assertTrue(session2.enableAllEvents());
+ assertTrue(session3.enableAllEvents());
+ assertTrue(session1.start());
+ assertTrue(session2.start());
+ assertTrue(session3.start());
+
+ sendEventsToLoggers();
+
+ assertTrue(session1.stop());
+ assertTrue(session2.stop());
+ assertTrue(session3.stop());
+
+ List<String> output1 = session1.view();
+ List<String> output2 = session2.view();
+ List<String> output3 = session3.view();
+ assertNotNull(output1);
+ assertNotNull(output2);
+ assertNotNull(output3);
+ assertEquals(40, output1.size());
+ assertEquals(40, output2.size());
+ assertEquals(40, output3.size());
+
+ assertEquals(10, handlerA.getEventCount());
+ assertEquals(10, handlerB.getEventCount());
+ assertEquals(10, handlerC.getEventCount());
+ assertEquals(10, handlerD.getEventCount());
+ }
+
+ /**
+ * Test enabling some events in some sessions only.
+ */
+ @Test
+ public void testSomeEvents() {
+ assertTrue(session1.enableEvents(EVENT_NAME_A));
+ assertTrue(session2.enableEvents(EVENT_NAME_B));
+ assertTrue(session1.start());
+ assertTrue(session2.start());
+ assertTrue(session3.start());
+
+ sendEventsToLoggers();
+
+ assertTrue(session1.stop());
+ assertTrue(session2.stop());
+ assertTrue(session3.stop());
+
+ List<String> output1 = session1.view();
+ List<String> output2 = session2.view();
+ List<String> output3 = session3.view();
+ assertNotNull(output1);
+ assertNotNull(output2);
+ assertNotNull(output3);
+ assertEquals(10, output1.size());
+ assertEquals(10, output2.size());
+ assertEquals(0, output3.size());
+
+ assertEquals(10, handlerA.getEventCount());
+ assertEquals(10, handlerB.getEventCount());
+ assertEquals(0, handlerC.getEventCount());
+ assertEquals(0, handlerD.getEventCount());
+ }
+
+ /**
+ * Test with all events enabled in one session, and some others in another.
+ * All events should arrive where expected, with no duplicates.
+ */
+ @Test
+ public void testAllEventsAndSome() {
+ assertTrue(session1.enableAllEvents());
+ assertTrue(session2.enableEvents(EVENT_NAME_D));
+ assertTrue(session1.start());
+ assertTrue(session2.start());
+ assertTrue(session3.start());
+
+ sendEventsToLoggers();
+
+ assertTrue(session1.stop());
+ assertTrue(session2.stop());
+ assertTrue(session3.stop());
+
+ List<String> output1 = session1.view();
+ List<String> output2 = session2.view();
+ List<String> output3 = session3.view();
+ assertNotNull(output1);
+ assertNotNull(output2);
+ assertNotNull(output3);
+ assertEquals(40, output1.size());
+ assertEquals(10, output2.size());
+ assertEquals(0, output3.size());
+
+ assertEquals(10, handlerA.getEventCount());
+ assertEquals(10, handlerB.getEventCount());
+ assertEquals(10, handlerC.getEventCount());
+ assertEquals(10, handlerD.getEventCount());
+ }
+
+ /**
+ * Test with enabling then disabling some events. Makes sure the refcounting
+ * works properly.
+ */
+ @Test
+ public void testSomeEventsAfterDisabling() {
+ assertTrue(session1.enableEvents(EVENT_NAME_A, EVENT_NAME_B, EVENT_NAME_C));
+ assertTrue(session2.enableEvents(EVENT_NAME_B, EVENT_NAME_C, EVENT_NAME_D));
+ assertTrue(session3.enableEvents(EVENT_NAME_A));
+
+ assertTrue(session1.disableEvents(EVENT_NAME_C));
+ assertTrue(session2.disableEvents(EVENT_NAME_B, EVENT_NAME_C));
+ assertTrue(session3.disableEvents(EVENT_NAME_A));
+
+ assertTrue(session1.start());
+ assertTrue(session2.start());
+ assertTrue(session3.start());
+
+ sendEventsToLoggers();
+
+ assertTrue(session1.stop());
+ assertTrue(session2.stop());
+ assertTrue(session3.stop());
+
+ List<String> output1 = session1.view();
+ List<String> output2 = session2.view();
+ List<String> output3 = session3.view();
+ assertNotNull(output1);
+ assertNotNull(output2);
+ assertNotNull(output3);
+ assertEquals(20, output1.size());
+ assertEquals(10, output2.size());
+ assertEquals(0, output3.size());
+
+ assertEquals(10, handlerA.getEventCount());
+ assertEquals(10, handlerB.getEventCount());
+ assertEquals(0, handlerC.getEventCount());
+ assertEquals(10, handlerD.getEventCount());
+ }
+
+ /**
+ * Test with a prefix in one session and a standard event in another.
+ */
+ @Test
+ public void testPrefixAndEvent() {
+ assertTrue(session1.enableEvents("EventAB*"));
+ assertTrue(session3.enableEvents(EVENT_NAME_A));
+ assertTrue(session1.start());
+ assertTrue(session2.start());
+ assertTrue(session3.start());
+
+ sendEventsToLoggers();
+
+ assertTrue(session1.stop());
+ assertTrue(session2.stop());
+ assertTrue(session3.stop());
+
+ List<String> output1 = session1.view();
+ List<String> output2 = session2.view();
+ List<String> output3 = session3.view();
+ assertNotNull(output1);
+ assertNotNull(output2);
+ assertNotNull(output3);
+ assertEquals(30, output1.size());
+ assertEquals(0, output2.size());
+ assertEquals(10, output3.size());
+
+ assertEquals(10, handlerA.getEventCount());
+ assertEquals(10, handlerB.getEventCount());
+ assertEquals(10, handlerC.getEventCount());
+ assertEquals(10, handlerD.getEventCount());
+ }
+
+ /**
+ * Test with all events enabled in one session, and an event prefix in
+ * another. Once again, there should be no duplicates.
+ */
+ @Test
+ public void testAllEventsAndPrefix() {
+ assertTrue(session1.enableAllEvents());
+ assertTrue(session2.enableEvents("EventABC*"));
+ assertTrue(session1.start());
+ assertTrue(session2.start());
+ assertTrue(session3.start());
+
+ sendEventsToLoggers();
+
+ assertTrue(session1.stop());
+ assertTrue(session2.stop());
+ assertTrue(session3.stop());
+
+ List<String> output1 = session1.view();
+ List<String> output2 = session2.view();
+ List<String> output3 = session3.view();
+ assertNotNull(output1);
+ assertNotNull(output2);
+ assertNotNull(output3);
+ assertEquals(40, output1.size());
+ assertEquals(20, output2.size());
+ assertEquals(0, output3.size());
+
+ assertEquals(10, handlerA.getEventCount());
+ assertEquals(10, handlerB.getEventCount());
+ assertEquals(10, handlerC.getEventCount());
+ assertEquals(10, handlerD.getEventCount());
+ }
+}
--- /dev/null
+package org.lttng.ust.agent.integration.jul;
+
+import static org.junit.Assume.assumeTrue;
+
+import java.io.IOException;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.lttng.ust.agent.integration.EnabledEventsTestBase;
+import org.lttng.ust.agent.jul.LttngLogHandler;
+import org.lttng.ust.agent.utils.LttngSession;
+import org.lttng.ust.agent.utils.LttngSession.Domain;
+import org.lttng.ust.agent.utils.MiscTestUtils;
+
+public class JulEnabledEventsTest extends EnabledEventsTestBase {
+
+ private static final Domain DOMAIN = Domain.JUL;
+
+ private Logger loggerA;
+ private Logger loggerB;
+ private Logger loggerC;
+ private Logger loggerD;
+
+ @BeforeClass
+ public static void julClassSetup() {
+ /* Skip tests if we can't find the JNI library or lttng-tools */
+ assumeTrue(MiscTestUtils.checkForJulLibrary());
+ assumeTrue(MiscTestUtils.checkForLttngTools(Domain.JUL));
+
+ LttngSession.destroyAllSessions();
+ }
+
+ @AfterClass
+ public static void julClassCleanup() {
+ LttngSession.deleteAllTracee();
+ }
+
+ @Before
+ public void julSetup() throws SecurityException, IOException {
+ loggerA = Logger.getLogger(EVENT_NAME_A);
+ loggerB = Logger.getLogger(EVENT_NAME_B);
+ loggerC = Logger.getLogger(EVENT_NAME_C);
+ loggerD = Logger.getLogger(EVENT_NAME_D);
+
+ loggerA.setLevel(Level.ALL);
+ loggerB.setLevel(Level.ALL);
+ loggerC.setLevel(Level.ALL);
+ loggerD.setLevel(Level.ALL);
+
+ handlerA = new LttngLogHandler();
+ handlerB = new LttngLogHandler();
+ handlerC = new LttngLogHandler();
+
+ loggerA.addHandler((Handler) handlerA);
+ loggerB.addHandler((Handler) handlerB);
+ loggerC.addHandler((Handler) handlerC);
+ }
+
+ @After
+ public void julTeardown() {
+ loggerA.removeHandler((Handler) handlerA);
+ loggerB.removeHandler((Handler) handlerB);
+ loggerC.removeHandler((Handler) handlerC);
+
+ loggerA = null;
+ loggerB = null;
+ loggerC = null;
+ loggerD = null;
+ }
+
+ @Override
+ protected Domain getDomain() {
+ return DOMAIN;
+ }
+
+ @Override
+ protected void sendEventsToLoggers() {
+ JulTestUtils.send10EventsTo(loggerA);
+ JulTestUtils.send10EventsTo(loggerB);
+ JulTestUtils.send10EventsTo(loggerC);
+ JulTestUtils.send10EventsTo(loggerD);
+ }
+}
--- /dev/null
+package org.lttng.ust.agent.integration.jul;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
+
+import java.lang.reflect.Field;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.lttng.ust.agent.ILttngHandler;
+import org.lttng.ust.agent.LTTngAgent;
+import org.lttng.ust.agent.utils.LttngSession;
+import org.lttng.ust.agent.utils.LttngSession.Domain;
+import org.lttng.ust.agent.utils.MiscTestUtils;
+
+@SuppressWarnings("deprecation")
+public class JulLegacyApiTest {
+
+ private static final Domain DOMAIN = Domain.JUL;
+
+ private static final String EVENT_NAME_A = "EventA";
+ private static final String EVENT_NAME_B = "EventB";
+
+ private LttngSession session;
+
+ private Logger loggerA;
+ private Logger loggerB;
+
+ @BeforeClass
+ public static void julClassSetup() {
+ /* Skip tests if we can't find the JNI library or lttng-tools */
+ assumeTrue(MiscTestUtils.checkForJulLibrary());
+ assumeTrue(MiscTestUtils.checkForLttngTools(Domain.JUL));
+
+ LttngSession.destroyAllSessions();
+ }
+
+ @AfterClass
+ public static void julClassCleanup() {
+ LttngSession.deleteAllTracee();
+ }
+
+ @Before
+ public void setup() {
+ loggerA = Logger.getLogger(EVENT_NAME_A);
+ LTTngAgent.getLTTngAgent();
+ loggerB = Logger.getLogger(EVENT_NAME_B);
+
+ loggerA.setLevel(Level.ALL);
+ loggerB.setLevel(Level.ALL);
+
+ session = new LttngSession(null, DOMAIN);
+ }
+
+ @After
+ public void tearDown() {
+ session.close();
+
+ LTTngAgent.dispose();
+
+ loggerA = null;
+ loggerB = null;
+ }
+
+ @Test
+ public void testNoEvents() {
+ assertTrue(session.start());
+
+ JulTestUtils.send10EventsTo(loggerA);
+ JulTestUtils.send10EventsTo(loggerB);
+
+ assertTrue(session.stop());
+
+ List<String> output = session.view();
+ assertNotNull(output);
+ assertTrue(output.isEmpty());
+
+ ILttngHandler handler = getAgentHandler();
+ assertEquals(0, handler.getEventCount());
+ }
+
+ @Test
+ public void testAllEvents() {
+ assertTrue(session.enableAllEvents());
+ assertTrue(session.start());
+
+ JulTestUtils.send10EventsTo(loggerA);
+ JulTestUtils.send10EventsTo(loggerB);
+
+ assertTrue(session.stop());
+
+ List<String> output = session.view();
+ assertNotNull(output);
+ assertEquals(20, output.size());
+
+ ILttngHandler handler = getAgentHandler();
+ assertEquals(20, handler.getEventCount());
+ }
+
+ @Test
+ public void testSomeEvents() {
+ assertTrue(session.enableEvents(EVENT_NAME_A));
+ assertTrue(session.start());
+
+ JulTestUtils.send10EventsTo(loggerA);
+ JulTestUtils.send10EventsTo(loggerB);
+
+ assertTrue(session.stop());
+
+ List<String> output = session.view();
+ assertNotNull(output);
+ assertEquals(10, output.size());
+
+ ILttngHandler handler = getAgentHandler();
+ assertEquals(10, handler.getEventCount());
+ }
+
+ /**
+ * Get the singleton JUL Handler currently managed by the LTTngAgent. It is
+ * not public, so we need reflection to access it.
+ *
+ * @return The agent's JUL handler
+ */
+ private static ILttngHandler getAgentHandler() {
+ try {
+ Field julHandlerField = LTTngAgent.class.getDeclaredField("julHandler");
+ julHandlerField.setAccessible(true);
+ return (ILttngHandler) julHandlerField.get(LTTngAgent.getLTTngAgent());
+ } catch (ReflectiveOperationException | SecurityException e) {
+ fail();
+ return null;
+ }
+ }
+
+}
+
--- /dev/null
+package org.lttng.ust.agent.integration.jul;
+
+import static org.junit.Assume.assumeTrue;
+
+import java.io.IOException;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.lttng.ust.agent.integration.MultiSessionTestBase;
+import org.lttng.ust.agent.jul.LttngLogHandler;
+import org.lttng.ust.agent.utils.LttngSession;
+import org.lttng.ust.agent.utils.LttngSession.Domain;
+import org.lttng.ust.agent.utils.MiscTestUtils;
+
+public class JulMultiSessionTest extends MultiSessionTestBase {
+
+ private static final Domain DOMAIN = Domain.JUL;
+
+ private Logger loggerA;
+ private Logger loggerB;
+ private Logger loggerC;
+ private Logger loggerD;
+
+ @BeforeClass
+ public static void julClassSetup() {
+ /* Skip tests if we can't find the JNI library or lttng-tools */
+ assumeTrue(MiscTestUtils.checkForJulLibrary());
+ assumeTrue(MiscTestUtils.checkForLttngTools(Domain.JUL));
+
+ LttngSession.destroyAllSessions();
+ }
+
+ @AfterClass
+ public static void julClassCleanup() {
+ LttngSession.deleteAllTracee();
+ }
+
+ @Before
+ public void julSetup() throws SecurityException, IOException {
+ loggerA = Logger.getLogger(EVENT_NAME_A);
+ loggerB = Logger.getLogger(EVENT_NAME_B);
+ loggerC = Logger.getLogger(EVENT_NAME_C);
+ loggerD = Logger.getLogger(EVENT_NAME_D);
+
+ loggerA.setLevel(Level.ALL);
+ loggerB.setLevel(Level.ALL);
+ loggerC.setLevel(Level.ALL);
+ loggerD.setLevel(Level.ALL);
+
+ handlerA = new LttngLogHandler();
+ handlerB = new LttngLogHandler();
+ handlerC = new LttngLogHandler();
+ handlerD = new LttngLogHandler();
+
+ loggerA.addHandler((Handler) handlerA);
+ loggerB.addHandler((Handler) handlerB);
+ loggerC.addHandler((Handler) handlerC);
+ loggerD.addHandler((Handler) handlerD);
+ }
+
+ @After
+ public void julTeardown() {
+ loggerA.removeHandler((Handler) handlerA);
+ loggerB.removeHandler((Handler) handlerB);
+ loggerC.removeHandler((Handler) handlerC);
+ loggerD.removeHandler((Handler) handlerD);
+
+ loggerA = null;
+ loggerB = null;
+ loggerC = null;
+ loggerD = null;
+ }
+
+ @Override
+ protected Domain getDomain() {
+ return DOMAIN;
+ }
+
+ @Override
+ protected void sendEventsToLoggers() {
+ JulTestUtils.send10EventsTo(loggerA);
+ JulTestUtils.send10EventsTo(loggerB);
+ JulTestUtils.send10EventsTo(loggerC);
+ JulTestUtils.send10EventsTo(loggerD);
+ }
+}
--- /dev/null
+package org.lttng.ust.agent.integration.jul;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+final class JulTestUtils {
+
+ JulTestUtils() {
+ }
+
+ static void send10EventsTo(Logger logger) {
+ String a = new String("a");
+ Object[] params = { a, new String("b"), new Object() };
+
+ // Levels are FINE, FINER, FINEST, INFO, SEVERE, WARNING
+ logger.fine("A fine level message");
+ logger.finer("A finer level message");
+ logger.finest("A finest level message");
+ logger.info("A info level message");
+ logger.severe("A severe level message");
+ logger.warning("A warning level message");
+ logger.warning("Another warning level message");
+ logger.log(Level.WARNING, "A warning message using Logger.log()");
+ logger.log(Level.INFO, "A message with one parameter", a);
+ logger.log(Level.INFO, "A message with parameters", params);
+ }
+}
--- /dev/null
+package org.lttng.ust.agent.integration.log4j;
+
+import static org.junit.Assume.assumeTrue;
+
+import java.io.IOException;
+
+import org.apache.log4j.Appender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.lttng.ust.agent.integration.EnabledEventsTestBase;
+import org.lttng.ust.agent.log4j.LttngLogAppender;
+import org.lttng.ust.agent.utils.LttngSession;
+import org.lttng.ust.agent.utils.LttngSession.Domain;
+import org.lttng.ust.agent.utils.MiscTestUtils;
+
+public class Log4jEnabledEventsTest extends EnabledEventsTestBase {
+
+ private static final Domain DOMAIN = Domain.LOG4J;
+
+ private Logger loggerA;
+ private Logger loggerB;
+ private Logger loggerC;
+ private Logger loggerD;
+
+ @BeforeClass
+ public static void log4jClassSetup() {
+ /* Skip tests if we can't find the JNI library or lttng-tools */
+ assumeTrue(MiscTestUtils.checkForLog4jLibrary());
+ assumeTrue(MiscTestUtils.checkForLttngTools(Domain.LOG4J));
+
+ LttngSession.destroyAllSessions();
+ }
+
+ @AfterClass
+ public static void log4jClassCleanup() {
+ LttngSession.deleteAllTracee();
+ }
+
+ @Before
+ public void log4jSetup() throws SecurityException, IOException {
+ loggerA = Logger.getLogger(EVENT_NAME_A);
+ loggerB = Logger.getLogger(EVENT_NAME_B);
+ loggerC = Logger.getLogger(EVENT_NAME_C);
+ loggerD = Logger.getLogger(EVENT_NAME_D);
+
+ loggerA.setLevel(Level.ALL);
+ loggerB.setLevel(Level.ALL);
+ loggerC.setLevel(Level.ALL);
+ loggerD.setLevel(Level.ALL);
+
+ handlerA = new LttngLogAppender();
+ handlerB = new LttngLogAppender();
+ handlerC = new LttngLogAppender();
+
+ loggerA.addAppender((Appender) handlerA);
+ loggerB.addAppender((Appender) handlerB);
+ loggerC.addAppender((Appender) handlerC);
+ }
+
+ @After
+ public void log4jTeardown() {
+ loggerA.removeAppender((Appender) handlerA);
+ loggerB.removeAppender((Appender) handlerB);
+ loggerC.removeAppender((Appender) handlerC);
+
+ loggerA = null;
+ loggerB = null;
+ loggerC = null;
+ loggerD = null;
+ }
+
+ @Override
+ protected Domain getDomain() {
+ return DOMAIN;
+ }
+
+ @Override
+ protected void sendEventsToLoggers() {
+ Log4jTestUtils.send10Events(loggerA);
+ Log4jTestUtils.send10Events(loggerB);
+ Log4jTestUtils.send10Events(loggerC);
+ Log4jTestUtils.send10Events(loggerD);
+ }
+}
--- /dev/null
+package org.lttng.ust.agent.integration.log4j;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
+
+import java.lang.reflect.Field;
+import java.util.List;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.lttng.ust.agent.ILttngHandler;
+import org.lttng.ust.agent.LTTngAgent;
+import org.lttng.ust.agent.utils.LttngSession;
+import org.lttng.ust.agent.utils.LttngSession.Domain;
+import org.lttng.ust.agent.utils.MiscTestUtils;
+
+@SuppressWarnings("deprecation")
+public class Log4jLegacyApiTest {
+
+ private static final Domain DOMAIN = Domain.LOG4J;
+
+ private static final String EVENT_NAME_A = "EventA";
+ private static final String EVENT_NAME_B = "EventB";
+
+ private LttngSession session;
+
+ private Logger loggerA;
+ private Logger loggerB;
+
+ @BeforeClass
+ public static void classSetup() {
+ /* Skip tests if we can't find the JNI library or lttng-tools */
+ assumeTrue(MiscTestUtils.checkForLog4jLibrary());
+ assumeTrue(MiscTestUtils.checkForLttngTools(Domain.LOG4J));
+
+ LttngSession.destroyAllSessions();
+ }
+
+ @AfterClass
+ public static void classCleanup() {
+ LttngSession.deleteAllTracee();
+ }
+
+ @Before
+ public void setup() {
+ loggerA = Logger.getLogger(EVENT_NAME_A);
+ LTTngAgent.getLTTngAgent();
+ loggerB = Logger.getLogger(EVENT_NAME_B);
+
+ loggerA.setLevel(Level.ALL);
+ loggerB.setLevel(Level.ALL);
+
+ session = new LttngSession(null, DOMAIN);
+ }
+
+ @After
+ public void tearDown() {
+ session.close();
+
+ LTTngAgent.dispose();
+
+ loggerA = null;
+ loggerB = null;
+ }
+
+ @Test
+ public void testNoEvents() {
+ assertTrue(session.start());
+
+ Log4jTestUtils.send10Events(loggerA);
+ Log4jTestUtils.send10Events(loggerB);
+
+ assertTrue(session.stop());
+
+ List<String> output = session.view();
+ assertNotNull(output);
+ assertTrue(output.isEmpty());
+
+ ILttngHandler handler = getAgentHandler();
+ assertEquals(0, handler.getEventCount());
+ }
+
+ @Test
+ public void testAllEvents() {
+ assertTrue(session.enableAllEvents());
+ assertTrue(session.start());
+
+ Log4jTestUtils.send10Events(loggerA);
+ Log4jTestUtils.send10Events(loggerB);
+
+ assertTrue(session.stop());
+
+ List<String> output = session.view();
+ assertNotNull(output);
+ assertEquals(20, output.size());
+
+ ILttngHandler handler = getAgentHandler();
+ assertEquals(20, handler.getEventCount());
+ }
+
+ @Test
+ public void testSomeEvents() {
+ assertTrue(session.enableEvents(EVENT_NAME_A));
+ assertTrue(session.start());
+
+ Log4jTestUtils.send10Events(loggerA);
+ Log4jTestUtils.send10Events(loggerB);
+
+ assertTrue(session.stop());
+
+ List<String> output = session.view();
+ assertNotNull(output);
+ assertEquals(10, output.size());
+
+ ILttngHandler handler = getAgentHandler();
+ assertEquals(10, handler.getEventCount());
+ }
+
+ /**
+ * Get the singleton Log4j Handler currently managed by the LTTngAgent. It
+ * is not public, so we need reflection to access it.
+ *
+ * @return The agent's Log4j handler
+ */
+ private static ILttngHandler getAgentHandler() {
+ try {
+ Field log4jAppenderField = LTTngAgent.class.getDeclaredField("log4jAppender");
+ log4jAppenderField.setAccessible(true);
+ return (ILttngHandler) log4jAppenderField.get(LTTngAgent.getLTTngAgent());
+ } catch (ReflectiveOperationException | SecurityException e) {
+ fail();
+ return null;
+ }
+ }
+
+}
+
--- /dev/null
+package org.lttng.ust.agent.integration.log4j;
+
+import static org.junit.Assume.assumeTrue;
+
+import java.io.IOException;
+
+import org.apache.log4j.Appender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.lttng.ust.agent.integration.MultiSessionTestBase;
+import org.lttng.ust.agent.log4j.LttngLogAppender;
+import org.lttng.ust.agent.utils.LttngSession;
+import org.lttng.ust.agent.utils.LttngSession.Domain;
+import org.lttng.ust.agent.utils.MiscTestUtils;
+
+public class Log4jMultiSessionTest extends MultiSessionTestBase {
+
+ private static final Domain DOMAIN = Domain.LOG4J;
+
+ private Logger loggerA;
+ private Logger loggerB;
+ private Logger loggerC;
+ private Logger loggerD;
+
+ @BeforeClass
+ public static void log4jClassSetup() {
+ /* Skip tests if we can't find the JNI library or lttng-tools */
+ assumeTrue(MiscTestUtils.checkForLog4jLibrary());
+ assumeTrue(MiscTestUtils.checkForLttngTools(Domain.LOG4J));
+
+ LttngSession.destroyAllSessions();
+ }
+
+ @AfterClass
+ public static void log4jClassCleanup() {
+ LttngSession.deleteAllTracee();
+ }
+
+ @Before
+ public void log4jSetup() throws SecurityException, IOException {
+ // TODO Wipe all existing LTTng sessions?
+
+ loggerA = Logger.getLogger(EVENT_NAME_A);
+ loggerB = Logger.getLogger(EVENT_NAME_B);
+ loggerC = Logger.getLogger(EVENT_NAME_C);
+ loggerD = Logger.getLogger(EVENT_NAME_D);
+
+ loggerA.setLevel(Level.ALL);
+ loggerB.setLevel(Level.ALL);
+ loggerC.setLevel(Level.ALL);
+ loggerD.setLevel(Level.ALL);
+
+ handlerA = new LttngLogAppender();
+ handlerB = new LttngLogAppender();
+ handlerC = new LttngLogAppender();
+ handlerD = new LttngLogAppender();
+
+ loggerA.addAppender((Appender) handlerA);
+ loggerB.addAppender((Appender) handlerB);
+ loggerC.addAppender((Appender) handlerC);
+ loggerD.addAppender((Appender) handlerD);
+ }
+
+ @After
+ public void log4jTeardown() {
+ loggerA.removeAppender((Appender) handlerA);
+ loggerB.removeAppender((Appender) handlerB);
+ loggerC.removeAppender((Appender) handlerC);
+ loggerD.removeAppender((Appender) handlerD);
+
+ loggerA = null;
+ loggerB = null;
+ loggerC = null;
+ loggerD = null;
+ }
+
+ @Override
+ protected Domain getDomain() {
+ return DOMAIN;
+ }
+
+ @Override
+ protected void sendEventsToLoggers() {
+ Log4jTestUtils.send10Events(loggerA);
+ Log4jTestUtils.send10Events(loggerB);
+ Log4jTestUtils.send10Events(loggerC);
+ Log4jTestUtils.send10Events(loggerD);
+ }
+}
--- /dev/null
+package org.lttng.ust.agent.integration.log4j;
+
+import java.io.IOException;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
+final class Log4jTestUtils {
+
+ private Log4jTestUtils() {
+ }
+
+ static void send10Events(Logger logger) {
+ // Levels/priorities are DEBUG, ERROR, FATAL, INFO, TRACE, WARN
+ logger.debug("Debug message. Lost among so many.");
+ logger.debug("Debug message with a throwable", new IOException());
+ logger.error("Error messsage. This might be bad.");
+ logger.error("Error message with a throwable", new IOException());
+ logger.fatal("A fatal message. You are already dead.");
+ logger.info("A info message. Lol, who cares.");
+ logger.trace("A trace message. No, no *that* trace");
+ logger.warn("A warn message. Yellow underline.");
+ logger.log(Level.DEBUG, "A debug message using .log()");
+ logger.log(Level.ERROR, "A error message using .log()");
+ }
+}
--- /dev/null
+package org.lttng.ust.agent.utils;
+
+import java.io.IOException;
+import java.lang.ProcessBuilder.Redirect;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.Arrays;
+import java.util.List;
+import java.util.UUID;
+import java.util.stream.Collectors;
+
+public class LttngSession implements AutoCloseable {
+
+ public enum Domain {
+ JUL("-j"),
+ LOG4J("-l");
+
+ private final String flag;
+
+ private Domain(String flag) {
+ this.flag = flag;
+ }
+
+ public String flag() {
+ return flag;
+ }
+ }
+
+ private final String sessionName;
+ private final Domain domain;
+
+ private volatile boolean channelCreated = false;
+
+ public LttngSession(String sessionName, Domain domain) {
+ if (sessionName != null) {
+ this.sessionName = sessionName;
+ } else {
+ this.sessionName = UUID.randomUUID().toString();
+ }
+ this.domain = domain;
+
+ /* Create the session in LTTng */
+ executeCommand(Arrays.asList("lttng", "create", this.sessionName));
+ }
+
+ @Override
+ public void close() {
+ /* Destroy the session */
+ executeCommand(Arrays.asList("lttng", "destroy", sessionName));
+ // FIXME also delete the trace we generated ?
+ }
+
+ // ------------------------------------------------------------------------
+ // Public methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Enable all events in the given session (enable-event -a)
+ *
+ * @return If the command executed successfully (return code = 0).
+ */
+ public boolean enableAllEvents() {
+ channelCreated = true;
+ return executeCommand(Arrays.asList(
+ "lttng", "enable-event", domain.flag(), "-a", "-s", sessionName));
+ }
+
+ /**
+ * Enable individual event(s).
+ *
+ * @param enabledEvents
+ * The list of events to enable. Should not be null or empty
+ * @return If the command executed successfully (return code = 0).
+ */
+ public boolean enableEvents(String... enabledEvents) {
+ if (enabledEvents == null || enabledEvents.length == 0) {
+ throw new IllegalArgumentException();
+ }
+ channelCreated = true;
+ return executeCommand(Arrays.asList(
+ "lttng", "enable-event", domain.flag(),
+ Arrays.stream(enabledEvents).collect(Collectors.joining(",")),
+ "-s", sessionName));
+ }
+
+ /**
+ * Send a disable-event command. Used to disable events that were previously
+ * enabled.
+ *
+ * @param disabledEvents
+ * The list of disabled events. Should not be null or empty
+ * @return If the command executed successfully (return code = 0).
+ */
+ public boolean disableEvents(String... disabledEvents) {
+ if (disabledEvents == null || disabledEvents.length == 0) {
+ throw new IllegalArgumentException();
+ }
+ return executeCommand(Arrays.asList(
+ "lttng", "disable-event", domain.flag(),
+ Arrays.stream(disabledEvents).collect(Collectors.joining(",")),
+ "-s", sessionName));
+ }
+
+ public boolean start() {
+ /*
+ * We have to enable a channel for 'lttng start' to work. However, we
+ * cannot enable a channel directly, see
+ * https://bugs.lttng.org/issues/894 . Instead we will enable an event
+ * we know does not exist
+ */
+ if (!channelCreated) {
+ enableEvents("non-event");
+ }
+ return executeCommand(Arrays.asList("lttng", "start", sessionName));
+ }
+
+ /**
+ * Stop the tracing session
+ *
+ * @return If the command executed successfully (return code = 0).
+ */
+ public boolean stop() {
+ return executeCommand(Arrays.asList("lttng", "stop", sessionName));
+ }
+
+ /**
+ * Issue a "lttng view" command on the session, and returns its output. This
+ * effectively returns the current content of the trace in text form.
+ *
+ * @return The output of Babeltrace on the session's current trace
+ */
+ public List<String> view() {
+ return MiscTestUtils.getOutputFromCommand(Arrays.asList("lttng", "view", sessionName));
+ }
+
+ /**
+ * Utility method to destroy all existing sessions. Useful when first
+ * setting up a test to make sure no existing session interferes.
+ */
+ public static void destroyAllSessions() {
+ executeCommand(Arrays.asList("lttng", "destroy", "-a"));
+ }
+
+ /**
+ * Outside of the scope of lttng-tools, but this utility method can be used
+ * to delete all traces currently under ~/lttng-traces/. This can be used by
+ * tests to cleanup a trace they have created.
+ *
+ * @return True if the command completes successfully, false if there was an
+ * error.
+ */
+ public static boolean deleteAllTracee() {
+ String tracesDir = new String(System.getProperty("user.home") + "/lttng-traces/");
+ return deleteDirectory(Paths.get(tracesDir));
+ }
+
+ // ------------------------------------------------------------------------
+ // Private helper methods
+ // ------------------------------------------------------------------------
+
+ private static boolean deleteDirectory(Path directory) {
+ try {
+ Files.walkFileTree(directory, new SimpleFileVisitor<Path>() {
+ @Override
+ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
+ Files.delete(file);
+ return FileVisitResult.CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
+ Files.delete(dir);
+ return FileVisitResult.CONTINUE;
+ }
+ });
+ } catch (IOException e) {
+ /* At least we tried... */
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Just to test the environment / stdout are working correctly
+ */
+ public static void main(String[] args) {
+ List<String> command = Arrays.asList("ls", "-l");
+ executeCommand(command);
+ }
+
+ private static boolean executeCommand(List<String> command) {
+ try {
+ ProcessBuilder builder = new ProcessBuilder(command);
+ builder.redirectErrorStream(true);
+ builder.redirectOutput(Redirect.INHERIT);
+
+ Process p = builder.start();
+ int ret = p.waitFor();
+ return (ret == 0);
+
+ } catch (IOException | InterruptedException e) {
+ return false;
+ }
+ }
+}
--- /dev/null
+package org.lttng.ust.agent.utils;
+
+import java.io.IOException;
+import java.lang.ProcessBuilder.Redirect;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.List;
+
+import org.lttng.ust.agent.jul.LttngLogHandler;
+import org.lttng.ust.agent.log4j.LttngLogAppender;
+import org.lttng.ust.agent.utils.LttngSession.Domain;
+
+/**
+ * Utility methods to help with UST-Java tests
+ */
+public final class MiscTestUtils {
+
+ private MiscTestUtils() {}
+
+ /**
+ * Check the the JUL native library is available, effectively allowing LTTng
+ * JUL handlers to be used.
+ *
+ * @return True if JUL works fine, false if it does not.
+ */
+ public static boolean checkForJulLibrary() {
+ try {
+ LttngLogHandler testHandler = new LttngLogHandler();
+ testHandler.close();
+ } catch (SecurityException | IOException e) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Check the the Log4j native library is available, effectively allowing
+ * LTTng Log4j appenders to be used.
+ *
+ * @return True if Log4j works fine, false if it does not.
+ */
+ public static boolean checkForLog4jLibrary() {
+ try {
+ LttngLogAppender testAppender = new LttngLogAppender();
+ testAppender.close();
+ } catch (SecurityException | IOException e) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Check that lttng-tools and babeltrace are installed on the system and
+ * working.
+ *
+ * @param domain
+ * The tracing domain to test for (we will try to setup a session
+ * with this domain)
+ * @return True if the environment should allow tracing fine, false if there
+ * was an error
+ */
+ public static boolean checkForLttngTools(Domain domain) {
+ try (LttngSession session = new LttngSession(null, domain)) {
+ boolean ret1 = session.enableAllEvents();
+ boolean ret2 = session.start();
+ boolean ret3 = session.stop();
+ /*
+ * "lttng view" also tests that Babeltrace is installed and working
+ */
+ List<String> contents = session.view();
+ return (ret1 && ret2 && ret3 && contents.isEmpty());
+ }
+ }
+
+ public static boolean checkForUserSessiond() {
+ String userName = System.getProperty("user.name");
+
+ /* The user name is truncated to 7 characters in "ps" */
+ String shortUserName = userName.substring(0, Math.min(userName.length(), 7));
+
+ List<String> command = Arrays.asList("ps", "-e", "u");
+ List<String> output = getOutputFromCommand(false, command);
+ return output.stream()
+ .filter(s -> s.contains("lttng-sessiond"))
+ .anyMatch(s -> s.startsWith(shortUserName));
+ }
+
+ public static boolean checkForRootSessiond() {
+ List<String> command = Arrays.asList("ps", "-e", "u");
+ List<String> output = getOutputFromCommand(false, command);
+ return output.stream()
+ .filter(s -> s.contains("lttng-sessiond"))
+ .anyMatch(s -> s.startsWith("root"));
+ }
+
+
+ static List<String> getOutputFromCommand(List<String> command) {
+ return MiscTestUtils.getOutputFromCommand(true, command);
+ }
+
+ static List<String> getOutputFromCommand(boolean print, List<String> command) {
+ try {
+ Path tempFile = Files.createTempFile("test-output", null);
+
+ ProcessBuilder builder = new ProcessBuilder(command);
+ builder.redirectErrorStream(true);
+ builder.redirectOutput(Redirect.to(tempFile.toFile()));
+
+ Process p = builder.start();
+ p.waitFor();
+
+ List<String> lines = Files.readAllLines(tempFile);
+ Files.delete(tempFile);
+
+ if (print) {
+ /* Also print the output to the console */
+ lines.stream().forEach(s -> System.out.println(s));
+ }
+
+ return lines;
+
+ } catch (IOException | InterruptedException e) {
+ return null;
+ }
+ }
+}