Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions test/cmdparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,22 @@ def test_port_with_icmp_fails_flag(self):
self.assertIn('port number specified (-P)', reply.stderr)
self.assertIn('protocol is ICMP', reply.stderr)

def test_report_loss_uses_two_decimal_places(self):
'Test report mode preserves fine-grained loss percentage precision.'

reply = self.run_mtr(
'--report',
'--report-cycles',
'1',
'--no-dns',
'127.0.0.1',
)

self.assertEqual(reply.returncode, 0)
self.assertEqual(reply.stderr, '')
self.assertIn('Loss%', reply.stdout)
self.assertIn('0.00%', reply.stdout)

def test_port_with_tcp_succeeds_flag(self):
'Test that specifying -P with -T (TCP) succeeds.'

Expand Down
2 changes: 1 addition & 1 deletion ui/gtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ static void percent_formatter(
gfloat f;
gchar text[64];
gtk_tree_model_get(tree_model, iter, POINTER_TO_INT(data), &f, -1);
snprintf(text, sizeof(text), "%.1f%%", f);
snprintf(text, sizeof(text), "%.2f%%", f);
g_object_set(cell, "text", text, NULL);
}

Expand Down
2 changes: 1 addition & 1 deletion ui/mtr.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ char *myname;
const struct fields data_fields[MAXFLD] = {
/* key, Remark, Header, Format, Width, CallBackFunc */
{' ', "<sp>: Space between fields", " ", " ", 1, &net_drop},
{'L', "L: Loss Ratio", "Loss%", " %4.1f%%", 6, &net_loss},
{'L', "L: Loss Ratio", "Loss%", " %6.2f%%", 8, &net_loss},
{'D', "D: Dropped Packets", "Drop", " %4d", 5, &net_drop},
{'R', "R: Received Packets", "Rcv", " %5d", 6, &net_returned},
{'S', "S: Sent Packets", "Snt", " %5d", 6, &net_xmit},
Expand Down
Loading