sapling/eden/scm/tests/test-fb-hgext-sigtrace.t
Jun Wu 5d5fca5d6c sigtrace: support collecting sigtrace periodically automatically
Summary:
There are lots of "hanging" questions in the support group. While not all of
them are our fault (ex. mergedriver), we don't have an easy reply to tell
users what's actually going on.

This diff adds a way to write sigtrace periodically so we can include it in
rage output.

Reviewed By: sfilipco

Differential Revision: D22009699

fbshipit-source-id: 5349f613b08507ed02cc0e3fa00963fd7d4c3d21
2020-06-23 14:11:49 -07:00

53 lines
1.3 KiB
Perl

$ newext signal <<EOF
> from edenscm.mercurial import registrar
> import os, signal
> cmdtable = {}
> command = registrar.command(cmdtable)
> @command('signal', norepo=True)
> def signalcommand(ui, *pats, **kwds):
> os.kill(os.getpid(), getattr(signal, 'SIG' + pats[0]))
> EOF
$ enable sigtrace
$ setconfig sigtrace.pathformat="$TESTTMP/dump-%(pid)s-%(time)s.log"
Test the default SIGUSR1 signal
$ hg signal USR1 2>&1 | tail -1
* written to $TESTTMP/dump-*.log (glob)
$ ls $TESTTMP/dump-*.log
$TESTTMP/dump-*-*.log (glob)
$ grep Thread $TESTTMP/dump-*.log | head -n 1
Thread *: (glob)
$ rm $TESTTMP/dump-*.log
Test the signal config option
$ echo 'signal=USR2' >> $HGRCPATH
$ echo 'memsignal=USR1' >> $HGRCPATH
$ hg signal USR2 2>&1 | tail -1
* written to $TESTTMP/dump-*.log (glob)
$ ls $TESTTMP/dump-*.log
$TESTTMP/dump-*-*.log (glob)
$ grep Thread $TESTTMP/dump-*.log | head -n 1
Thread *: (glob)
$ rm $TESTTMP/dump-*.log
$ echo 'signal=INVALIDSIGNAL' >> $HGRCPATH
$ echo 'memsignal=INVALIDSIGNAL' >> $HGRCPATH
$ hg signal USR1 || false
* (glob)
[1]
$ ls $TESTTMP/dump-*.log || false
ls: * (glob)
[1]
Test the interval config option
$ newrepo
$ setconfig sigtrace.interval=1
$ hg dbsh -c 'import time; time.sleep(2)'
$ ls .hg/sigtrace/
pid-*-debugshell (glob)