# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# verify: read to analyze stack info
#   limit: per stack snapshot dump limit
#   stack: per data means one snapshot, stack elements split by "-"
# expected: need verify data analyze result
#   info: follow this pattern: codeSignature(duration:durationExcludeChild)
#   children: all children nodes

list:
  # case 1
  - data:
      limit: 10
      timeRanges: 0-2
      snapshots:
        - A-B-C
        - A-B
        - A-B-C-D
    expected:
      - code: A
        count: 3
        duration: 20:0
        children:
          - code: B
            count: 3
            duration: 20:20
            children:
              - code: C
                count: 2
                duration: 0:0
                children:
                  - code: D
                    count: 1
                    duration: 0:0

  # case 2
  - data:
      limit: 10
      timeRanges: 0-1
      snapshots:
        - A-B-C
        - B-C-D
    expected:
      - code: A
        count: 1
        duration: 0:0
        children:
          - code: B
            count: 1
            duration: 0:0
            children:
              - code: C
                count: 1
                duration: 0:0
      - code: B
        count: 1
        duration: 0:0
        children:
          - code: C
            count: 1
            duration: 0:0
            children:
              - code: D
                count: 1
                duration: 0:0

  # case 3
  - data:
      limit: 10
      timeRanges: 0-4
      snapshots:
        - A-B-C-D
        - A-B
        - A-B-C
        - A-B
        - A-B-C-D
    expected:
      - code: A
        count: 5
        duration: 40:0
        children:
          - code: B
            count: 5
            duration: 40:40
            children:
              - code: C
                count: 3
                duration: 0:0
                children:
                  - code: D
                    count: 2
                    duration: 0:0

  # case 4:
  - data:
      limit: 10
      timeRanges: 0-3
      snapshots:
        - A-B-C
        - A-B-C-A
        - A-C-A
        - A-B-C-B
    expected:
      - code: A
        count: 4
        duration: 30:20
        children:
          - code: B
            count: 3
            duration: 10:0
            children:
              - code: C
                count: 3
                duration: 10:10
                children:
                  - code: A
                    count: 1
                    duration: 0:0
                  - code: B
                    count: 1
                    duration: 0:0
          - code: C
            count: 1
            duration: 0:0
            children:
              - code: A
                count: 1
                duration: 0:0

  # case 5:
  - data:
      limit: 10
      timeRanges: 0-3
      snapshots:
        - A-B-C
        - A-B-B-C
        - A-B-B-B
        - A-C-B
    expected:
      - code: A
        count: 4
        duration: 30:10
        children:
          - code: B
            count: 3
            duration: 20:10
            children:
              - code: C
                count: 1
                duration: 0:0
              - code: B
                count: 2
                duration: 10:10
                children:
                  - code: C
                    count: 1
                    duration: 0:0
                  - code: B
                    count: 1
                    duration: 0:0
          - code: C
            count: 1
            duration: 0:0
            children:
              - code: B
                count: 1
                duration: 0:0

  # case 6:
  - data:
      limit: 10
      timeRanges: 0-2
      snapshots:
        - A-B-C
        - A-B
        - D-E
    expected:
      - code: A
        count: 2
        duration: 10:0
        children:
          - code: B
            count: 2
            duration: 10:10
            children:
              - code: C
                count: 1
                duration: 0:0
      - code: D
        count: 1
        duration: 0:0
        children:
          - code: E
            count: 1
            duration: 0:0

  # case 7(only analyze first 10 snapshots):
  - data:
      limit: 10
      timeRanges: 0-10
      snapshots:
        - A
        - A
        - A
        - A
        - A
        - A
        - A
        - A
        - A
        - A
        - A
    expected:
      - code: A
        count: 10
        duration: 90:90

  # case 8(multiple time ranges)
  - data:
      limit: 10
      timeRanges: 0-2,4-5
      snapshots:
        - A
        - A
        - A
        - A-C
        - A
        - A
        - A-D
    expected:
      - code: A
        count: 5
        duration: 30:30

  # case 9(multiple time ranges with overlapping time)
  - data:
      limit: 10
      timeRanges: 0-2,1-3,5-6
      snapshots:
        - A
        - A
        - A
        - A
        - B
        - A
        - A
    expected:
      - code: A
        count: 6
        duration: 40:40
