-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestsuite.xp
executable file
·797 lines (674 loc) · 20.3 KB
/
testsuite.xp
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
#!/usr/bin/expect
#-*-sh-*-
# This expect script performs some basic testing of mserv. It
# requires two user accounts to exist; "johan" with password "johan"
# and "root" with password "root". "johan" should be a normal user
# and "root" a superuser. It also requires at least one song in one
# album and an otherwise working configuration.
#
# This script must be run when mserv has just started, as it expects
# no history entries and nobody logged in to start with. A successful
# run ends with mserv being shut down.
#
# A failed run ends either with an error message or that the script
# execution just hangs
# Hang if something unexpected happens
set timeout -1
# Verifies that MServ remembers when the currently playing track was
# last played. This function expects the current user to be human.
proc verify_playing_track { } {
send_user "Giving mserv a chance to forget when the current track was last played...\n"
sleep 5
send "info\n"
expect "Track name"
# Verify that mserv remembers when the current track was last played
expect {
-re {Played: +([0-9]+) ([a-zA-Z]+) ago} {
set amount $expect_out(1,string)
set unit $expect_out(2,string)
if { $unit == "seconds" && $amount <= 10 } then {
send_error "*** The info command says the just started song was last played only $amount seconds ago\n"
exit 1
}
}
-re {Played: +never}
}
# Verify that mserv gives a penalty to the currently playing song
expect -re {temporally adjusted to +([0-9]+\.[0-9])%}
set percentage $expect_out(1,string)
if { $percentage > 10.0 } then {
send_error "*** The info command says the current song hasn't gotten enough temporal penalty\n"
exit 1
}
}
# Strip leading zeroes from a number
proc stripzeros {value} {
regsub ^0+(.+) $value \\1 retval
return $retval
}
# Log in as Johan and mess around
spawn telnet localhost 4444
set humanjohan $spawn_id
expect "USER"
send "user johan\n"
expect "PASS"
send "pass johan\n"
expect "Welcome johan"
# Log in as a computerized Johan and lurk
spawn telnet localhost 4444
set computerjohan $spawn_id
expect "USER"
expect "\n.\n"
send "user johan\n"
expect "PASS"
expect "\n.\n"
send "pass johan rtcomputer\n"
expect "202"
expect "Welcome johan"
expect "\n.\n"
expect -i $humanjohan "johan has connected"
send "history\n"
expect "412 There are no entries in the history"
# Default to operating on the human user
set spawn_id $humanjohan
send "who\n"
expect "The following people are online"
expect "johan"
expect "johan"
send "agdgdaagdgad\n"
expect "not understood"
# Test the factor command
send "factor auto\n"
expect -re {Random play factor set to [0-9.]+, auto-tuning enabled by johan}
expect -i $computerjohan -re {=617\t[0-9.]+\tjohan\tenabled}
send "factor\n"
expect "auto-tuning is enabled"
send "factor 0.6\n"
expect "Random play factor set to 0.60, auto-tuning disabled by johan"
expect -i $computerjohan "=617\t0.60\tjohan\tdisabled"
send "factor\n"
expect "auto-tuning is disabled"
# Test only bogus rating commands, root will test actual re-ratings
send "rate\n"
expect "Bad rate type"
send "rate neutral\n"
expect "Nothing playing"
send "rate 999999 neutral\n"
expect "No such album"
send "rate 1 999999 neutral\n"
expect "No such track"
send "ratings\n"
expect "Nothing playing"
send "ratings 1 1\n"
expect "Ratings of track"
send "history\n"
expect "no entries"
send "userinfo\n"
expect "User johan"
expect "Satisfaction:"
send "userinfo root\n"
expect "User root"
expect "Satisfaction:"
send "tracks\n"
expect "Nothing playing"
send "tracks 1\n"
expect "Tracks in album"
send "asearch kljhlkhufwiuytrqwerfskhuiwregf\n"
expect "No albums matching"
send "search kljhlkhufwiuytrqwerfskhuiwregf\n"
expect "No tracks matching"
send "status\n"
expect "Nothing currently playing"
send "stop\n"
expect "Nothing playing"
send "pause\n"
expect "Nothing playing"
send "top\n"
expect "Most likely to be played tracks"
send "albums\n"
expect "Albums available"
send "queue\n"
expect "no tracks in the queue"
send "queue 1 1\n"
expect "The following tracks have been added to the queue"
expect -i $computerjohan "=618\tjohan"
expect -i $computerjohan "=619\tjohan\t1\t1"
send "queue\n"
expect "The following tracks are in the queue"
send "unqueue 1 1\n"
expect "unqueued by johan"
expect -i $computerjohan "=627\tjohan\t1\t1"
send "next\n"
expect "Nothing playing"
send "volume\n"
expect "Volume is currently"
send "info\n"
expect "Nothing playing"
send "info 1\n"
expect "Album name"
send "info 1 1\n"
expect "Track name"
# Start playing and try some commands again
send "play\n"
expect "Playing"
expect -re {random +([0-9]+)/([0-9]+) }
set albumnumber $expect_out(1,string)
set tracknumber $expect_out(2,string)
send "status\n"
expect "Track name"
expect -re {Time playing: +([0-9]+):([0-9][0-9])[^0-9]}
set minutes $expect_out(1,string)
set seconds [stripzeros $expect_out(2,string)]
if { $minutes > 0 || $seconds >= 2 } then {
send_error "*** The status command says the just started song has played too long\n"
exit 1
}
# What comes next is really the result of the "play" command, not
# "status".
# The reason we don't wait for the computer being notified about that
# a new song has started playing before we do "status" is that doing
# things this way has previously uncovered a bug. We don't want that
# bug to re-appear in the future, so please don't change the order of
# "play", "status" and "expect -i $computerjohan" here.
expect -i $computerjohan -re {=622\trandom\t([0-9]+)\t([0-9]+)\t}
if { $expect_out(1,string) != $albumnumber ||
$expect_out(2,string) != $tracknumber } then {
send_error "*** Human thinks $albumnumber/$tracknumber is playing but root thinks $expect_out(1,string)/$expect_out(2,string)\n"
exit 1
}
send "ratings\n"
expect "Ratings of track"
send "history\n"
expect "The following tracks were recently played"
send "tracks\n"
expect "Tracks in album"
send "pause\n"
expect "paused"
expect -i $computerjohan "=606\tjohan"
send "pause\n"
expect "Already paused"
send "play\n"
expect "resumed by johan"
expect -i $computerjohan "=605\tjohan"
send "next\n"
expect "Track skipped"
expect "Playing:"
expect -i $computerjohan "=629\tjohan"
expect -i $computerjohan "=622\trandom"
send "info $albumnumber $tracknumber\n"
# Verify that the last track is reported as having been played very
# recently
expect -re {Played: +([0-9]+) ([a-zA-Z]+) ago}
set amount $expect_out(1,string)
set unit $expect_out(2,string)
if { $unit != "seconds" || $amount > 5 } then {
send_error "*** The info command says the last song was last played $amount $unit ago, which is too long ago\n"
exit 1
}
# Verify that the last track received a temporal penalty for having
# been played recently
expect -re {temporally adjusted to +([0-9]+\.[0-9])%}
set percentage $expect_out(1,string)
if { $percentage > 10.0 } then {
send_error "*** The info command says the last song didn't get enough temporal penalty\n"
exit 1
}
verify_playing_track
send "play\n"
expect "Already playing"
send "stop\n"
expect "stopped"
expect -i $computerjohan "=623\tjohan"
send "quit\n"
expect {
eof { send_error "*** Human logged out without a goodbye!!\n" ; exit 1 }
"Goodbye"
}
expect -i $computerjohan "=601\tjohan"
wait
# Log johan back in so we can do the same thing all over, only this
# time it will be the computer client that does all the work and the
# human only verifies that it gets notified about what happens.
spawn telnet localhost 4444
set humanjohan $spawn_id
expect "USER"
send "user johan\n"
expect "PASS"
send "pass johan\n"
expect "Welcome johan"
expect -i $computerjohan "=600\tjohan"
# Default to operating on the computer user
set spawn_id $computerjohan
send "who\n"
expect "226 The following people are online"
expect "johan"
expect "johan"
expect "\n.\n"
send "agdgdaagdgad\n"
expect "500 Command not understood"
# Test the factor command
send "factor auto\n"
expect "239 Random play factor set to 0.60, auto-tuning enabled"
expect "0.60\tenabled"
expect -i $humanjohan "Random play factor set to 0.60, auto-tuning enabled by johan"
send "factor\n"
expect "238 Random play factor is currently 0.60, auto-tuning is enabled"
expect "0.60\tenabled"
send "factor 0.6\n"
expect "239 Random play factor set to 0.60, auto-tuning disabled"
expect "0.60\tdisabled"
expect -i $humanjohan "Random play factor set to 0.60, auto-tuning disabled by johan"
send "factor\n"
expect "238 Random play factor is currently 0.60, auto-tuning is disabled"
expect "0.60\tdisabled"
# Test only bogus rating commands, root will test actual re-ratings
send "rate\n"
expect "518 Bad rate type"
send "rate neutral\n"
expect "401 Nothing playing"
send "rate 999999 neutral\n"
expect "508 No such album"
send "rate 1 999999 neutral\n"
expect "509 No such track"
send "ratings\n"
expect "401 Nothing playing"
send "ratings 1 1\n"
expect "229 Ratings of track"
expect "\n.\n"
send "status\n"
expect "224 Nothing currently playing"
expect "\n.\n"
send "history\n"
expect "241 The following tracks were recently played"
expect "\n.\n"
send "userinfo\n"
expect "246 User johan"
expect "johan\tjohan\t"
expect "\n.\n"
send "userinfo root\n"
expect "246 User root"
expect "root\tjohan\t"
expect "\n.\n"
send "tracks\n"
expect "401 Nothing playing"
send "tracks 1\n"
expect "228 Tracks in album"
expect "\n.\n"
send "asearch kljhlkhufwiuytrqwerfskhuiwregf\n"
expect "538 No albums"
send "search kljhlkhufwiuytrqwerfskhuiwregf\n"
expect "520 No tracks"
send "stop\n"
expect "401 Nothing playing"
send "pause\n"
expect "401 Nothing playing"
send "top\n"
expect "234 Most likely to be played"
expect "\n.\n"
send "albums\n"
expect "227 Albums available"
expect "\n.\n"
send "queue\n"
expect "404 There are no tracks in the queue"
expect "\n.\n"
send "queue 1 1\n"
expect "247 The following tracks have been added to the queue"
expect "\n.\n"
expect -i $humanjohan "The following tracks have been added to the queue"
send "queue\n"
expect "225 The following tracks are in the queue"
expect "\n.\n"
send "unqueue 1 1\n"
expect "254 Track"
expect -i $humanjohan "unqueued by johan"
send "next\n"
expect "401 Nothing playing"
send "volume\n"
expect "235 Volume is currently"
send "info\n"
expect "401 Nothing playing"
expect "\n.\n"
send "info 1\n"
expect "245 Album 1"
expect "\n.\n"
send "info 1 1\n"
expect "246 Album 1, track 1"
expect "\n.\n"
# Start playing and try some commands again
send "play\n"
expect "230 Play commenced"
expect "\n.\n"
expect -i $humanjohan "Playing:"
send "status\n"
expect "222 Playing"
# Verify that the "play commenced" timestamp is recent
expect -re {[^\t]*\t[0-9]+\t[0-9]+\t[0-9]+\t[0-9]+\t[^\t]*\t[^\t]*\t([0-9]+)\t}
if { [expr abs([clock seconds] - $expect_out(1,string))] > 1 } then {
send_error "*** The status command says the just started song commenced playing $expect_out(1,string)\n"
send_error " but the current time is [clock seconds]\n"
exit 1
}
# Verify that the amount of time the current song has been playing is
# on the format M:SS, which is what MServClient expects.
expect -re {[0-9]+:[0-5][0-9]\t}
expect "\n.\n"
send "ratings\n"
expect "229 Ratings of track"
expect "\n.\n"
send "tracks\n"
expect "228 Tracks in album"
expect "\n.\n"
send "pause\n"
expect "232 Play paused"
expect -i $humanjohan "paused by johan"
send "pause\n"
expect "406 Already paused"
send "play\n"
expect "230 Play commenced"
expect "\n.\n"
expect -i $humanjohan "resumed by johan"
send "next\n"
expect "240 Moved to next track"
expect -i $humanjohan "Track skipped"
expect -i $humanjohan "Playing: "
send "info\n"
expect "246 Album"
expect "\n.\n"
send "play\n"
expect "402 Already playing"
send "stop\n"
expect "231 Play stopped"
expect "\n.\n"
expect -i $humanjohan "stopped by johan"
send "quit\n"
expect {
eof { send_error "*** Computer logged out without a goodbye!!\n" ; exit 1 }
"220 Goodbye"
}
wait
expect -i $humanjohan "johan has disconnected"
# Verify that the song timing doesn't get messed up by pausing a song
set spawn_id $humanjohan
send "play\n"
expect "Playing:"
send_user "Waiting for music to start...\n"
sleep 3
send "pause\n"
expect "paused"
send "status\n"
expect -re {Time playing: +[0-9]+:([0-9][0-9])\.([0-9])}
set seconds [stripzeros $expect_out(1,string)]
set tenths $expect_out(2,string)
set t0 [expr 10 * $seconds + $tenths]
if { $t0 == 0 } then {
send_error "*** Internal error in test script, music didn't start in three seconds\n"
exit 1
}
send_user "Giving mserv a chance to mess up the timing...\n"
sleep 1
send "status\n"
expect -re {Time playing: +[0-9]+:([0-9][0-9])\.([0-9])}
set seconds [stripzeros $expect_out(1,string)]
set tenths $expect_out(2,string)
set t1 [expr 10 * $seconds + $tenths]
send "stop\n"
expect "stopped"
if { $t1 != $t0 } then {
send_error "*** Song playing time keeps ticking according to \"status\" during pause\n"
exit 1
}
# Log the computer johan back in so he can be kicked off by root
spawn telnet localhost 4444
set computerjohan $spawn_id
expect "USER"
expect "\n.\n"
send "user johan\n"
expect "PASS"
expect "\n.\n"
send "pass johan rtcomputer\n"
expect "202"
expect "Welcome johan"
expect "\n.\n"
expect -i $humanjohan "johan has connected"
# Log in as root for testing root-only commands
spawn telnet localhost 4444
set humanroot $spawn_id
expect "USER"
send "user root\n"
expect "PASS"
send "pass root\n"
expect "Welcome root"
expect -i $humanjohan "root has connected"
expect -i $computerjohan "=600\troot"
# Verify that both Johans are still logged in
send "who\n"
expect "johan"
expect "johan"
send "kick johan\n"
expect "User johan has disconnected"
# Verify that the Johans actually disappeared
send "who\n"
expect "1 connected, 1 total"
# Verify that the human Johan got notified
set spawn_id $humanjohan
expect {
eof { send_error "*** Human kicked without notification!!\n" ; exit 1 }
"You have been kicked off"
}
wait
# Verify that the computer Johan gets notified
set spawn_id $computerjohan
expect {
eof { send_error "*** Computer kicked without notification!!\n" ; exit 1 }
"=526"
}
wait
# Log in as a computerized root
spawn telnet localhost 4444
set computerroot $spawn_id
expect "USER"
expect "\n.\n"
send "user root\n"
expect "PASS"
expect "\n.\n"
send "pass root rtcomputer\n"
expect "202"
expect "Welcome root"
expect "\n.\n"
expect -i $humanroot "root has connected"
# Back to the human root
set spawn_id $humanroot
# Test ratings. Better do this as root so we don't mess up Johan's
# ratings...
send "rate 1 1 awful\n"
expect "The track 1/1 has been rated AWFUL by root"
expect -i $computerroot "=614"
expect -i $computerroot "AWFUL"
send "rate 1 1 bad\n"
expect "The track 1/1 has been rated BAD by root"
expect -i $computerroot "=614"
expect -i $computerroot "BAD"
send "rate 1 1 good\n"
expect "The track 1/1 has been rated GOOD by root"
expect -i $computerroot "=614"
expect -i $computerroot "GOOD"
send "rate 1 1 superb\n"
expect "The track 1/1 has been rated SUPERB by root"
expect -i $computerroot "=614"
expect -i $computerroot "SUPERB"
send "rate 1 1 neutral\n"
expect "The track 1/1 has been rated NEUTRAL by root"
expect -i $computerroot "=614"
expect -i $computerroot "NEUTRAL"
send "ratings 1 1\n"
expect "root"
expect "NEUTRAL"
send "info 1 1\n"
expect "NEUTRAL"
send "play\n"
expect "Playing"
expect -i $computerroot "=622\trandom"
send "rate neutral\n"
expect "This track has been rated NEUTRAL by root"
# Note that the rtcomputer rating notification differs between "track
# foo has been rated" (=614) and "this track has been rated" (=615).
expect -i $computerroot "=615"
expect -i $computerroot "NEUTRAL"
send "ratings\n"
expect "root"
expect "NEUTRAL"
send "info\n"
expect "NEUTRAL"
send "stop\n"
expect "stopped"
expect -i $computerroot "=623\troot"
# Let the computer root rate stuff and verify that the human gets
# notified.
set spawn_id $computerroot
send "rate 1 1 awful\n"
expect "270"
expect "root"
expect "AWFUL"
expect -i $humanroot "The track 1/1 has been rated AWFUL by root"
send "rate 1 1 bad\n"
expect "270"
expect "root"
expect "BAD"
expect -i $humanroot "The track 1/1 has been rated BAD by root"
send "rate 1 1 good\n"
expect "270"
expect "root"
expect "GOOD"
expect -i $humanroot "The track 1/1 has been rated GOOD by root"
send "rate 1 1 superb\n"
expect "270"
expect "root"
expect "SUPERB"
expect -i $humanroot "The track 1/1 has been rated SUPERB by root"
send "rate 1 1 neutral\n"
expect "270"
expect "root"
expect "NEUTRAL"
expect -i $humanroot "The track 1/1 has been rated NEUTRAL by root"
send "ratings 1 1\n"
expect "229 Ratings of track"
expect "root\tNEUTRAL"
expect "\n.\n"
send "info 1 1\n"
expect "246 Album 1, track 1"
expect "NEUTRAL"
expect "\n.\n"
send "play\n"
expect "230 Play commenced"
expect "\n.\n"
expect -i $humanroot "Playing:"
send "rate neutral\n"
expect "270 Rated"
expect "root"
expect "NEUTRAL"
expect -i $humanroot "This track has been rated NEUTRAL by root"
send "ratings\n"
expect "229 Ratings of track"
expect "root\tNEUTRAL"
expect "\n.\n"
send "info\n"
expect "246 Album"
expect "NEUTRAL"
expect "\n.\n"
send "stop\n"
expect "231 Play stopped"
expect "\n.\n"
expect -i $humanroot "stopped by root"
# At last, let a whole song play to the end
set spawn_id $humanroot
send "play\n"
expect "Playing:"
expect -re { ([0-9]+)/([0-9]+) }
set currentAlbum $expect_out(1,string)
set currentTrack $expect_out(2,string)
set t0 [clock clicks -milliseconds]
# Verify that root got the same song the human did
expect -i $computerroot -re {=622\trandom\t([0-9]+)\t([0-9]+)\t}
if { $expect_out(1,string) != $currentAlbum ||
$expect_out(2,string) != $currentTrack } then {
send_error "*** Human thinks $currentAlbum/$currentTrack is playing but root thinks $expect_out(1,string)/$expect_out(2,string)\n"
exit 1
}
send_user "Waiting for song to finish...\n"
send_user "\n"
send_user "Most tests have passed, so unless you are about to check in changes, you can break here.\n"
# Wait for the track to finish playing by itself
expect "Playing:"
# Remember how long it took to play the song
set t1 [clock clicks -milliseconds]
set realduration [expr $t1 - $t0]
# Register the new song
set previousAlbum $currentAlbum
set previousTrack $currentTrack
expect -re { ([0-9]+)/([0-9]+) }
set currentAlbum $expect_out(1,string)
set currentTrack $expect_out(2,string)
# Verify that root got the same song the human did
expect -i $computerroot -re {=622\trandom\t([0-9]+)\t([0-9]+)\t}
if { $expect_out(1,string) != $currentAlbum ||
$expect_out(2,string) != $currentTrack } then {
send_error "*** Human thinks $currentAlbum/$currentTrack is playing but root thinks $expect_out(1,string)/$expect_out(2,string)\n"
exit 1
}
if { $currentAlbum == $previousAlbum &&
$currentTrack == $previousTrack } then {
send_error "*** Track $currentAlbum/$currentTrack played twice in a row!\n"
}
# Verify that the last track's duration as reported by "info" is
# somewhat realistic
send "info $previousAlbum $previousTrack\n"
expect -re {Duration: +([0-9]+):([0-9]+)}
set minutes $expect_out(1,string)
set seconds [stripzeros $expect_out(2,string)]
set infoduration [expr $minutes * 60 * 1000 + $seconds * 1000]
set difference [expr abs($infoduration - $realduration)]
if { $difference > 5000 } {
set infoseconds [expr $infoduration / 1000]
set realseconds [expr $realduration / 1000]
send_error "Info says track $previousAlbum/$previousTrack is $infoseconds seconds, but I just timed it to be $realseconds seconds.\n"
exit 1
}
# Verify that the last track got its last-played timestamp updated
expect -re {Played: +([0-9]+) ([a-zA-Z]+) ago}
set amount $expect_out(1,string)
set unit $expect_out(2,string)
if { $unit != "seconds" || $amount > 5 } then {
send_error "*** The info command says the just played song was last played $amount $unit ago, which is too long ago\n"
exit 1
}
# Verify that the last track received a temporal penalty for having
# been played recently
expect -re {temporally adjusted to +([0-9]+\.[0-9])%}
set percentage $expect_out(1,string)
if { $percentage > 10.0 } then {
send_error "*** The info command says the last song didn't get enough temporal penalty\n"
exit 1
}
# Verify the next track
set spawn_id $humanroot
verify_playing_track
# Stop playback
set spawn_id $computerroot
send "stop\n"
expect "231 Play stopped"
expect "\n.\n"
expect -i $humanroot "stopped by root"
# Let the human client shut down
set spawn_id $humanroot
send "shutdown\n"
expect {
eof { send_error "*** MServ shutdown without saying anything!!\n" ; exit 1 }
"shutdown by root"
}
wait
set spawn_id $computerroot
expect {
eof { send_error "*** MServ shutdown without notifying computer users!!\n" ; exit 1 }
"=633\troot"
}
wait