tests: drivers: uart: uart_pm: Minor adjustments in the test

Modifying arbitrary delay to cover for receivers with timeout.
Adding a delay between polling and asynchronous checking to cover
for cases when CPU processing is fast enough so that both checks
may overlap.
Allow error code for uart_rx_disable call.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
diff --git a/tests/drivers/uart/uart_pm/src/main.c b/tests/drivers/uart/uart_pm/src/main.c
index 6b64085..07e75ec 100644
--- a/tests/drivers/uart/uart_pm/src/main.c
+++ b/tests/drivers/uart/uart_pm/src/main.c
@@ -34,7 +34,10 @@
 
 	for (int i = 0; i < ARRAY_SIZE(outs); i++) {
 		uart_poll_out(dev, outs[i]);
-		k_busy_wait(1000);
+		/* We need to wait until receiver gets the data. Receiver may have
+		 * RX timeout so data is not received instantly.
+		 */
+		k_busy_wait(5000);
 
 		if (active) {
 			err = uart_poll_in(dev, &c);
@@ -78,6 +81,12 @@
 
 	zassert_equal(err, 0, "Unexpected err: %d", err);
 
+	/* Wait a bit to ensure that polling transfer is already finished otherwise
+	 * receiver might be enabled when there is an ongoing transfer and bytes
+	 * will get corrupted.
+	 */
+	k_busy_wait(1000);
+
 	if (!DISABLED_RX) {
 		err = uart_rx_enable(dev, rxbuf, sizeof(rxbuf), 1 * USEC_PER_MSEC);
 		zassert_equal(err, 0, "Unexpected err: %d", err);
@@ -90,7 +99,7 @@
 
 	if (!DISABLED_RX) {
 		err = uart_rx_disable(dev);
-		zassert_equal(err, 0, "Unexpected err: %d", err);
+		zassert_true((err == 0) || (err == -EFAULT));
 
 		k_busy_wait(10000);