STRLEN opsize;
const I32 id = SvIVx(*++mark);
SV * const opstr = *++mark;
- const char * const opbuf = SvPV_const(opstr, opsize);
+ const char * const opbuf = SvPVbyte(opstr, opsize);
PERL_ARGS_ASSERT_DO_SEMOP;
PERL_UNUSED_ARG(sp);
}
}
else {
- plan(tests => 15);
+ plan(tests => 22);
pass('acquired semaphore');
}
ok(!eval { semctl($id, $ignored, SETALL, $semvals); 1 },
"throws on code points above 0xff");
like($@, qr/Wide character/, "with the expected error");
+
+ {
+ # semop tests
+ ok(semctl($id, $sem2set, SETVAL, 0),
+ "reset our working entry");
+ # sanity check without UTF-8
+ my $op = pack "s!*", $sem2set, $semval, 0;
+ ok(semop($id, $op), "add to entry $sem2set");
+ is(semctl($id, $sem2set, GETVAL, 0), $semval,
+ "check it added to the entry");
+ utf8::upgrade($op);
+ # unlike semctl this doesn't throw on a bad size, so we don't need an
+ # eval with the buggy code
+ ok(semop($id, $op), "add more to entry $sem2set (UTF-8)");
+ is(semctl($id, $sem2set, GETVAL, 0), $semval*2,
+ "check it added to the entry");
+
+ substr($op, 0, 1) = chr(0x101);
+ ok(!eval { semop($id, $op); 1 },
+ "test semop throws if the op string isn't 'bytes'");
+ like($@, qr/Wide character/, "with the expected error");
+ }
}
{