Skip to content

Commit

Permalink
Prefer single quotes over double quotes in Python code
Browse files Browse the repository at this point in the history
  • Loading branch information
rocallahan committed May 30, 2024
1 parent 8d3c236 commit b63a3ce
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 49 deletions.
6 changes: 3 additions & 3 deletions src/test/breakpoint_overlap.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
'aarch64': ArchInfo('pc'),
}

syscall_re = re.compile("`SYSCALL: <unknown-syscall--1>' \\(state:EXITING_SYSCALL\\)")
sched_re = re.compile("`SCHED'")
eip_re = re.compile("%s:(0x[a-f0-9]+)" % regex_info[arch].ip_name)
syscall_re = re.compile(r'''`SYSCALL: <unknown-syscall--1>' \(state:EXITING_SYSCALL\)''')
sched_re = re.compile(r'`SCHED')
eip_re = re.compile(r'%s:(0x[a-f0-9]+)' % regex_info[arch].ip_name)

sched_enabled = False
eip_enabled = False
Expand Down
6 changes: 3 additions & 3 deletions src/test/check_syscall_perf_interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
expected_count = int(sys.argv[3])

last_perfctr_value = -1
syscall_re = re.compile("`SYSCALL: (\\w+)' \\(state:0\\)")
perfctr_re = re.compile(counter + ":(\\d+)")
syscall_re = re.compile(r'''`SYSCALL: (\\w+)' \\(state:0\\)''')
perfctr_re = re.compile(counter + ':(\\d+)')

while True:
line = sys.stdin.readline()
Expand All @@ -27,7 +27,7 @@
if m:
v = int(m.group(1))
if last_perfctr_value >= 0 and v - last_perfctr_value != expected_count:
print("Mismatch: saw %d %ss between %ss (from %d to %d), expected %d" % \
print('Mismatch: saw %d %ss between %ss (from %d to %d), expected %d' % \
(v - last_perfctr_value, counter, syscall, last_perfctr_value, v, expected_count))
sys.exit(1)
last_perfctr_value = v
Expand Down
4 changes: 2 additions & 2 deletions src/test/clone_interruption_finder.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import sys
import re

syscall_re = re.compile("`SIGNAL: ")
time_re = re.compile("global_time:(\d+)")
syscall_re = re.compile('`SIGNAL: ')
time_re = re.compile(r'global_time:(\d+)')
futex_time = 999999999

while True:
Expand Down
5 changes: 2 additions & 3 deletions src/test/elapsed_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
elapsed_time = float(last_match().group(0))
sleep_time = 1.0
if elapsed_time < sleep_time:
failed("ERROR ... The reported elapsed time after sleeping for " +
"{sleep_time} (s) was {elapsed_time}".format(
sleep_time=sleep_time, elapsed_time=elapsed_time))
failed('ERROR ... The reported elapsed time after sleeping for ' +
f'{sleep_time} (s) was {elapsed_time}')

ok()
16 changes: 8 additions & 8 deletions src/test/gdb_qpasssignals.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from util import *

send_gdb("handle SIGURG noprint nostop pass")
send_gdb("handle SIGKILL stop")
send_gdb('handle SIGURG noprint nostop pass')
send_gdb('handle SIGKILL stop')

send_gdb("c")
send_gdb('c')


expect_rr("XIT-END")
expect_rr('XIT-END')

send_gdb("b main")
expect_gdb("Breakpoint 1")
send_gdb("reverse-continue")
send_gdb('b main')
expect_gdb('Breakpoint 1')
send_gdb('reverse-continue')

expect_gdb("Breakpoint 1")
expect_gdb('Breakpoint 1')
ok()
4 changes: 2 additions & 2 deletions src/test/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
expect_gdb('i=4')

send_gdb('forward')
expect_gdb("Can't go forward. No more history entries.")
expect_gdb('Can\'t go forward. No more history entries.')

send_gdb('back')
expect_gdb('i=3')
Expand All @@ -34,7 +34,7 @@
send_gdb('c')
expect_gdb('i=1')
send_gdb('forward')
expect_gdb("Can't go forward. No more history entries.")
expect_gdb('Can\'t go forward. No more history entries.')

send_gdb('back')
expect_gdb('i=0')
Expand Down
2 changes: 1 addition & 1 deletion src/test/read_big_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
expect_gdb('(rr)')

send_gdb('p big')
expect_gdb("bytes = 'Z'")
expect_gdb('bytes = \'Z\'')

ok()
18 changes: 9 additions & 9 deletions src/test/seekticks.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,24 @@
if ticks3 <= ticks2:
failed('ERROR ... "when-ticks" failed to advance')

send_gdb("seek-ticks %d" % ticks2)
expect_gdb("Program stopped.")
send_gdb(f'seek-ticks {ticks2}')
expect_gdb('Program stopped.')
send_gdb('when-ticks')
expect_gdb(re.compile(r'Current tick: (\d+)'))
ticks4 = int(last_match().group(1))
if ticks4 != ticks2:
failed('ERROR: Failed to seek back to ticks2')

send_gdb("seek-ticks %d" % ticks)
expect_gdb("Program stopped.")
send_gdb(f'seek-ticks {ticks}')
expect_gdb('Program stopped.')
send_gdb('when-ticks')
expect_gdb(re.compile(r'Current tick: (\d+)'))
ticks5 = int(last_match().group(1))
if ticks5 != ticks:
failed('ERROR: Failed to seek back to ticks')

send_gdb("seek-ticks %d" % ticks2)
expect_gdb("Program stopped.")
send_gdb(f'seek-ticks {ticks2}')
expect_gdb('Program stopped.')
send_gdb('when-ticks')
expect_gdb(re.compile(r'Current tick: (\d+)'))
ticks6 = int(last_match().group(1))
Expand All @@ -64,13 +64,13 @@

for i in range(len(tests)):
ticks7 = tests[i]
send_gdb("seek-ticks %d" % ticks7)
expect_gdb("Program stopped.")
send_gdb(f'seek-ticks {ticks7}')
expect_gdb('Program stopped.')
send_gdb('when-ticks')
expect_gdb(re.compile(r'Current tick: (\d+)'))
ticks8 = int(last_match().group(1))
if ticks8 != ticks7:
failed("ERROR: seek-ticks didn't go to correct tick on test %d" % i)
failed(f'ERROR: seek-ticks didn\'t go to correct tick on test {i}')

send_gdb('seek-ticks 2000000000')
expect_gdb('No event found matching specified ticks target')
Expand Down
2 changes: 1 addition & 1 deletion src/test/signal_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
send_gdb('c')
expect_gdb('Breakpoint 1, sighandler')

send_gdb("restart 1");
send_gdb('restart 1');
send_gdb('c')
expect_gdb('Breakpoint 1, sighandler')

Expand Down
8 changes: 4 additions & 4 deletions src/test/tick0.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def get_when():
if ticks_end < 99999:
failed('End ticks too low')

send_gdb("seek-ticks %d" % ticks_start)
expect_gdb("Program stopped.")
send_gdb(f'seek-ticks {ticks_start}')
expect_gdb('Program stopped.')
(event_exp, ticks_from_end) = get_when()
if ticks_from_end != ticks_start:
failed('ERROR: Failed to seek back to tick 0 from end')
Expand All @@ -37,8 +37,8 @@ def get_when():
expect_gdb(re.compile(r'(Thread \d+|Program) stopped'))


send_gdb("seek-ticks %d" % ticks_start)
expect_gdb("Program stopped.")
send_gdb(f'seek-ticks {ticks_start}')
expect_gdb('Program stopped.')

(event, ticks) = get_when()
if ticks != 0:
Expand Down
26 changes: 13 additions & 13 deletions src/test/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ def interrupt_gdb():

def send_gdb(what):
assert debugger_type == 'GDB'
send(child, "%s\n"%what)
send(child, f'{what}\n')

def send_lldb(what):
assert debugger_type == 'LLDB'
send(child, "%s\n"%what)
send(child, f'{what}\n')

# Restarts and continues execution
def restart_replay(event=0):
Expand Down Expand Up @@ -106,21 +106,21 @@ def backtrace():

def expect_breakpoint_stop(number):
if debugger_type == 'GDB':
expect_debugger("Breakpoint %d"%number)
expect_debugger(f'Breakpoint {number}')
else:
expect_debugger("stop reason = breakpoint %d"%number)
expect_debugger(f'stop reason = breakpoint {number}')

def expect_watchpoint_stop(number):
if debugger_type == 'GDB':
expect_debugger("atchpoint %d"%number)
expect_debugger(f'atchpoint {number}')
else:
expect_debugger("stop reason = watchpoint %d"%number)
expect_debugger(f'stop reason = watchpoint {number}')

def expect_signal_stop(signal_name):
if debugger_type == 'GDB':
expect_debugger(f"received signal {signal_name}")
expect_debugger(f'received signal {signal_name}')
else:
expect_debugger(f"received signal: {signal_name}")
expect_debugger(f'received signal: {signal_name}')

def set_breakpoint_commands(number, commands):
if debugger_type == 'GDB':
Expand Down Expand Up @@ -154,10 +154,10 @@ def expect_threads(num_threads, selected_thread):

def select_thread(index):
if debugger_type == 'GDB':
send_gdb(f"thread {index}")
send_gdb(f'thread {index}')
expect_debugger(f'Switching to thread {index} ')
else:
send_lldb(f"thread select {index}")
send_lldb(f'thread select {index}')
expect_debugger(f'thread #{index}')

def scheduler_locking_on():
Expand Down Expand Up @@ -205,7 +205,7 @@ def clean_up():
child = None
except Exception as e:
if iterations < 5:
print("close() failed with '%s', retrying..."%e)
print(f'close() failed with "{e}", retrying...')
iterations = iterations + 1
else:
child = None
Expand All @@ -214,13 +214,13 @@ def expect(prog, what):
try:
prog.expect(what)
except Exception as e:
failed('expecting "%s"'% (what), e)
failed(f'expecting "{what}"', e)

def send(prog, what):
try:
prog.send(what)
except Exception as e:
failed('sending "%s"'% (what), e)
failed(f'sending "{what}"', e)

def set_up():
global child
Expand Down

0 comments on commit b63a3ce

Please sign in to comment.