File: test.liq

package info (click to toggle)
liquidsoap 1.3.3-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 4,504 kB
  • sloc: ml: 37,149; python: 956; makefile: 624; sh: 458; perl: 322; lisp: 124; ansic: 53; ruby: 8
file content (43 lines) | stat: -rw-r--r-- 989 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# End test successfully.
def test.pass()
  shutdown()
end

# End test with a failure.
def test.fail()
  exit(1)
end

# End test with signal 2
def test.skip()
  exit(2)
end

# Check that files are never repeated in source s, possibly by rounds. The
# function triggers test.fail on repeated filenames, only clearing its list of
# seen filenames once all nb_files have been seen.
def test.check_non_repeating(~nb_files,~nb_rounds,s)

  seen = ref([])       # List of seen filenames
  iterations = ref(0)  # Number of rounds to test

  def check(m)
    fname = m["filename"]
    cur_seen = !seen
    if !iterations < nb_rounds and cur_seen[fname] != "" then
      test.fail()
    else
      if list.length(!seen) < nb_files-1 then
        seen := list.add((fname,fname),!seen)
      else
        seen := []
        iterations := !iterations+1
        if !iterations == nb_rounds then
          test.pass()
        end
      end
    end
  end

  on_track(id="check_non_repeating",check,s)
end